草庐IT

CollectionView

全部标签

ios - UICollectionView - 滚动到第一个单元格

我正在使用UICollectionView,我需要在单击按钮后滚动到第一个单元格。该按钮位于我的收藏View中的(大)标题部分...单击它时,我需要滚动到位于该按钮下方的第一个单元格。我创建了这个按钮的Action,但我不知道如何滚动到第一个UICollectionViewCell。有人可以帮助我吗? 最佳答案 使用此委托(delegate)方法,将indexPath设置在第一个位置:swiftself.collectionView?.scrollToItemAtIndexPath(NSIndexPath(forItem:0,inS

ios - 如何更改 UICollectionView 中单元格之间的空间?

我想减小行中单元格之间的大小。现在看起来像:我正在尝试这样做,以减少它们之间的大小:letlayout:UICollectionViewFlowLayout=UICollectionViewFlowLayout()layout.sectionInset=UIEdgeInsets(top:20,left:2,bottom:10,right:2)layout.minimumInteritemSpacing=0layout.minimumLineSpacing=0但这对我没有帮助。我做错了什么? 最佳答案 //Objectivec-(CG

ios - 如何更改 UICollectionView 中单元格之间的空间?

我想减小行中单元格之间的大小。现在看起来像:我正在尝试这样做,以减少它们之间的大小:letlayout:UICollectionViewFlowLayout=UICollectionViewFlowLayout()layout.sectionInset=UIEdgeInsets(top:20,left:2,bottom:10,right:2)layout.minimumInteritemSpacing=0layout.minimumLineSpacing=0但这对我没有帮助。我做错了什么? 最佳答案 //Objectivec-(CG

ios - UICollectionView:在标题和项目之间添加间距

我想在标题和实际项目之间添加一些间距,目前看起来像这样:funccollectionView(collectionView:UICollectionView,viewForSupplementaryElementOfKindkind:String,atIndexPathindexPath:NSIndexPath)->UICollectionReusableView{//Createheaderswitchkind{caseUICollectionElementKindSectionHeader:letheaderView=iconCollectionView.dequeueReusab

ios - UICollectionView:在标题和项目之间添加间距

我想在标题和实际项目之间添加一些间距,目前看起来像这样:funccollectionView(collectionView:UICollectionView,viewForSupplementaryElementOfKindkind:String,atIndexPathindexPath:NSIndexPath)->UICollectionReusableView{//Createheaderswitchkind{caseUICollectionElementKindSectionHeader:letheaderView=iconCollectionView.dequeueReusab

ios - 如何在保持单元格选择的同时向 UICollectionView 添加点击手势?

任务向UICollectionView添加单击手势,不妨碍单元格选择。我想在collectionView的无单元格部分进行一些其他点击。代码使用XCode8、Swift3。overridefuncviewDidLoad(){...collectionView.addGestureRecognizer(UITapGestureRecognizer(target:self,action:#selector(tap)))}funccollectionView(_collectionView:UICollectionView,didSelectItemAtindexPath:IndexPath

ios - 如何在保持单元格选择的同时向 UICollectionView 添加点击手势?

任务向UICollectionView添加单击手势,不妨碍单元格选择。我想在collectionView的无单元格部分进行一些其他点击。代码使用XCode8、Swift3。overridefuncviewDidLoad(){...collectionView.addGestureRecognizer(UITapGestureRecognizer(target:self,action:#selector(tap)))}funccollectionView(_collectionView:UICollectionView,didSelectItemAtindexPath:IndexPath

ios - 如何快速获取 UICollectionView 中的 cell atIndex?

我正在以编程方式制作收藏View。这是viewDidLoad函数中的代码letlayout:UICollectionViewFlowLayout=UICollectionViewFlowLayout()layout.sectionInset=UIEdgeInsets(top:20,left:20,bottom:20,right:20)layout.itemSize=CGSize(width:90,height:120)collectionView=UICollectionView(frame:self.view.frame,collectionViewLayout:layout)col

ios - 如何快速获取 UICollectionView 中的 cell atIndex?

我正在以编程方式制作收藏View。这是viewDidLoad函数中的代码letlayout:UICollectionViewFlowLayout=UICollectionViewFlowLayout()layout.sectionInset=UIEdgeInsets(top:20,left:20,bottom:20,right:20)layout.itemSize=CGSize(width:90,height:120)collectionView=UICollectionView(frame:self.view.frame,collectionViewLayout:layout)col

ios - 动态高度 UITableViewCell 内的动态高度 UICollectionView

我有一个水平的UICollectionView固定到UITableViewCell的所有边缘。CollectionView中的项目是动态调整大小的,我想让TableView的高度等于最高的CollectionView单元格的高度。View的结构如下:UITableViewUITableViewCellUICollectionViewUICollectionViewCellUICollectionViewCellUICollectionViewCellclassTableViewCell:UITableViewCell{privatelazyvarcollectionView:UICol