Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/ios/111.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Ios UICollectionViewFlowLayout左侧的间隙_Ios_Swift_Uicollectionview_Uicollectionviewlayout - Fatal编程技术网

Ios UICollectionViewFlowLayout左侧的间隙

Ios UICollectionViewFlowLayout左侧的间隙,ios,swift,uicollectionview,uicollectionviewlayout,Ios,Swift,Uicollectionview,Uicollectionviewlayout,我使用UICollectionViewFlowLayout来显示网格视图,这就是我所看到的 问题在于左侧的间隙。我对使用UICollectionViewFlowLayout有点陌生,所以我不知道如何消除那里的差距 请帮助要减少左侧的空间,您可以在UICollectionViewFlowLayout上设置sectionInset属性 flowLayout.sectionInsets = UIEdgeInsets(top: 50.0, left: 0.0, bottom: 50.0, right:

我使用UICollectionViewFlowLayout来显示网格视图,这就是我所看到的

问题在于左侧的间隙。我对使用UICollectionViewFlowLayout有点陌生,所以我不知道如何消除那里的差距


请帮助

要减少左侧的空间,您可以在
UICollectionViewFlowLayout
上设置
sectionInset
属性

flowLayout.sectionInsets = UIEdgeInsets(top: 50.0, left: 0.0, bottom: 50.0, right: 0.0)
或者,您可以实现此方法:

func collectionView(collectionView: UICollectionView, layout collectionViewLayout: UICollectionViewLayout, insetForSectionAtIndex section: Int) -> UIEdgeInsets {
        return UIEdgeInsets(top: 50.0, left: 0.0, bottom: 50.0, right: 0.0)
   }
如果委托对象未实现 collectionView:layout:InsetForSectionIndex:method,流布局 使用此属性中的值设置每个部分的边距


来源:

要减少左侧的空间,您可以在
UICollectionViewFlowLayout
上设置
sectionInset
属性

flowLayout.sectionInsets = UIEdgeInsets(top: 50.0, left: 0.0, bottom: 50.0, right: 0.0)
或者,您可以实现此方法:

func collectionView(collectionView: UICollectionView, layout collectionViewLayout: UICollectionViewLayout, insetForSectionAtIndex section: Int) -> UIEdgeInsets {
        return UIEdgeInsets(top: 50.0, left: 0.0, bottom: 50.0, right: 0.0)
   }
如果委托对象未实现 collectionView:layout:InsetForSectionIndex:method,流布局 使用此属性中的值设置每个部分的边距

来源:

尝试使用:

 - (UIEdgeInsets)collectionView:(UICollectionView *)collectionView layout:(UICollectionViewLayout *)collectionViewLayout insetForSectionAtIndex:(NSInteger)section
{
  return UIEdgeInsetsMake(5, 5, 5, 5); //desired values
}
希望有帮助。

尝试使用:

 - (UIEdgeInsets)collectionView:(UICollectionView *)collectionView layout:(UICollectionViewLayout *)collectionViewLayout insetForSectionAtIndex:(NSInteger)section
{
  return UIEdgeInsetsMake(5, 5, 5, 5); //desired values
}

希望有帮助。

我的第一个猜测是查看
部分插图。您可以直接在流布局上设置它们:

flowLayout.sectionInsets = UIEdgeInsets(...)
或通过~UICollectionViewDelegateFlowLayout`方法:

optional func collectionView(_ collectionView: UICollectionView,
    layout collectionViewLayout: UICollectionViewLayout,
    insetForSectionAtIndex section: Int) -> UIEdgeInsets {

}


我的第一个猜测是检查
部分插图。您可以直接在流布局上设置它们:

flowLayout.sectionInsets = UIEdgeInsets(...)
或通过~UICollectionViewDelegateFlowLayout`方法:

optional func collectionView(_ collectionView: UICollectionView,
    layout collectionViewLayout: UICollectionViewLayout,
    insetForSectionAtIndex section: Int) -> UIEdgeInsets {

}


嘿。如果您使用的是自动布局,则问题可能在于页边距。检查
UICollectionView
Hey的前导约束。如果您使用的是自动布局,则问题可能在于页边距。检查
UICollectionView的前导约束