草庐IT

collectionView

全部标签

ios - 如何在 iOS CollectionView 的 Footer 中添加 loading Indicator

当为下一页加载数据时,如何在CollectionView的页脚中添加加载指示器......?我想像上图一样在CollectionView的页脚中加载指示器。但我无法做到这一点。所以这可能吗..?否则,我必须使用tableview创建这种类型的ListView。因为我们可以轻松地将这些东西管理到tableview中。如有任何帮助,我们将不胜感激。 最佳答案 最简单的解决方案是将事件指示器添加到View并将该View添加到UICollectionReusableView。在CollectionView中:privateletfooter

ios - 在不重新加载数据的情况下更改 UICollectionView 中的标签值?

我使用的是swift2.2,我在单元格内有一个CollectionView,它有一个标签。我想在单击按钮时更改UICollectionView中的标签文本值,而不使用重新加载整个uiCollectionView。我不能在我的场景中使用collectionView.reloadData()。我想要一个不使用它的方法。只是为了更新collectionview中特定项目中的一个标签。有帮助吗?? 最佳答案 如果您传递IndexPath,您可以访问该单元格,然后您可以使用此语法从中更改标签letcell=self.collectionVie

ios - 在 UICollectionView 中注册多个单元格(swift 3)

对于UICollectionViews,是否可以有多个单元格类型?例如:media_cellregular_cellad_cell您是只需要注册它们还是必须包含一个if语句并根据某个变量更改布局以实现此效果。例如:ifcell.ad==true{}原因是,当存在图像时,我想要一个稍微不同大小的单元格。我想调整单元格的大小可能会奏效,但我还没有在网上看到任何内容。任何建议 最佳答案 试试这个:1.注册两个(或多个)cell。2.为每个配置cellforItem。3.为每个配置sizeForItem。第一:self.collection

swift - 为什么我不能将 UICollectionViewCell 向下转换为它的子类?

我正在制作一个CollectionView,并制作了我自己的自定义collectionCell。我已经在身份检查器中指定了,据我所知,我做的一切都是正确的。代码是importUIKitclassSubjectCollectionViewCell:UICollectionViewCell{@IBOutletweakvarimageView:UIImageView!@IBOutletweakvarlabel:UILabel!}在我的collectionViewController中overridefunccollectionView(collectionView:UICollectionV

ios - 如何以编程方式将 CollectionView 滚动到底部

我使用这段代码来滚动CollectionView:letsection=(self.collectionView?.numberOfSections)!-1;letitem=(self.collectionView?.numberOfItems(inSection:section))!-1;letlastIndexPath=IndexPath(item:item,section:section);self.collectionView?.scrollToItem(at:lastIndexPath,at:.bottom,animated:true);但是我得到错误:*Terminatin

ios - 如何在 Swift 中添加 UICollectionView 的页眉和页脚 View

我在Controller类中添加了委托(delegate)函数,但它不会在运行时调用。funccollectionView(collectionView:UICollectionView,viewForSupplementaryElementOfKindkind:String,atIndexPathindexPath:NSIndexPath)->UICollectionReusableView{} 最佳答案 overridefunccollectionView(collectionView:UICollectionView,view

ios - Swift:UICollectionView 页脚未显示

我的UICollectionView的页脚没有显示它的任何subview。我四处寻找答案,但在我的案例中似乎没有任何效果。我不确定它是Swift中的东西还是我只是遗漏了一些东西。在我的Storyboard中,我选中了SectionFooter框并在页脚View中添加了几个按钮。我已将可重用标识符设置为footer并将其作为.然后我调用了collectionView(collectionView:UICollectionView!,viewForSupplementaryElementOfKindkind:String!,atIndexPathindexPath:NSIndexPath!

ios - 快速获取collectionView中心单元格的indexPath?

我已经尝试通过使用uicollectionview的扩展来获取CollectionView中心单元格的索引,但我总是得到nil而不是索引。我该如何解决这个问题?extensionUICollectionView{varcenterPoint:CGPoint{get{returnCGPoint(x:self.center.x+self.contentOffset.x,y:self.center.y+self.contentOffset.y);}}varcenterCellIndexPath:NSIndexPath?{ifletcenterIndexPath:NSIndexPath=sel

ios - Collection View :cellForItemAtIndexPath: why my view has zero subviews?

请考虑以下代码:funccollectionView(collectionView:UICollectionView,cellForItemAtIndexPathindexPath:NSIndexPath)->UICollectionViewCell{letcell=collectionView.dequeueReusableCellWithReuseIdentifier("DataItemCell",forIndexPath:indexPath)asDataItemCollectionViewCellprintln("\(cell.parametersView.subviews.co

swift - 扩展 UICollectionViewDataSource 协议(protocol)以添加默认实现

我有一个相当大的应用程序,它有很多CollectionView。大多数CollectionView对数据源和流布局委托(delegate)具有相同的实现(相同的大小、边距等)。我正在尝试创建一个协议(protocol),它提供UICollectionViewDataSource和UICollectionViewDelegateFlowLayout的默认实现。这是我的代码。protocolTiledCollectionView{}extensionUICollectionViewDataSourcewhereSelf:TiledCollectionView{//defaultimplem