草庐IT

UICollectionReusableView

全部标签

swift - UICollectionview scrollToItemAtIndexPath,在动画完成之前不加载可见单元格

我有一个包含142个单元格的UICollectionView。7.5随时可见。我正在将一个单元格从indexPath0移动到100。但我也想滚动到那个新位置。下面的代码工作正常。但它为移动和滚动设置动画,然后加载中央/移动单元格前后的单元格。我认为这是因为细胞是可重复使用的。但是对于142,我无法预加载所有这些这不是最好的效果,我想预加载新位置周围的单元格,indexPath100之前4个和之后4个,然后看移动和滚动的动画。你能帮忙吗?UIView.animateWithDuration(animationSpeed,animations:{()->Voidinself.collect

ios - CollectionViewLayout 补充 View 高度等于内容

我有一个UICollectionViewLayout子类,其中包含一个包含多行UILabel的补充View。问题是并非所有文本在某个点都是可见的,我怎样才能让补充View的高度等于它的内容? 最佳答案 您可以使用以下函数找到文本的高度:-funclabelHeight(width:CGFloat,font:UIFont,text:String)->CGFloat{letlabel:UILabel=UILabel.init(frame:CGRect.init(x:0,y:0,width:width,height:CGFloat.gre

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

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

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

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

ios - UICollectionView 添加了多个装饰 View

我正在创建一个基本的CollectionView布局,它是UICollectionViewFlowLayout的子类。但是,我注意到似乎有几个装饰View堆叠在一起。每当用户在上一节中选择一个项目时,我都会使用以下代码添加一个新节。似乎每当我执行这段代码时,装饰View的一个额外副本就会添加到每个已经存在的部分。[collectionViewperformBatchUpdates:^{currentModelArrayIndex++;[collectionViewinsertSections:[NSIndexSetindexSetWithIndex:currentModelArrayI

ios - UICollectionView 添加了多个装饰 View

我正在创建一个基本的CollectionView布局,它是UICollectionViewFlowLayout的子类。但是,我注意到似乎有几个装饰View堆叠在一起。每当用户在上一节中选择一个项目时,我都会使用以下代码添加一个新节。似乎每当我执行这段代码时,装饰View的一个额外副本就会添加到每个已经存在的部分。[collectionViewperformBatchUpdates:^{currentModelArrayIndex++;[collectionViewinsertSections:[NSIndexSetindexSetWithIndex:currentModelArrayI

ios - UICollectionView 和自定义 UICollectionReusableView 不起作用

我正在尝试在我的UICollectionViewheader中使用自定义UICollectionReusableView(它有自己的类和XIB)。但是在标题位置获取数据后,我什么都没有。我的步骤:在viewDidLoad中注册类:[self.collectionViewregisterClass:[CollectionViewHeaderclass]forSupplementaryViewOfKind:UICollectionElementKindSectionHeaderwithReuseIdentifier:@"HeaderView"];试图展示:-(UICollectionReu

ios - UICollectionView 和自定义 UICollectionReusableView 不起作用

我正在尝试在我的UICollectionViewheader中使用自定义UICollectionReusableView(它有自己的类和XIB)。但是在标题位置获取数据后,我什么都没有。我的步骤:在viewDidLoad中注册类:[self.collectionViewregisterClass:[CollectionViewHeaderclass]forSupplementaryViewOfKind:UICollectionElementKindSectionHeaderwithReuseIdentifier:@"HeaderView"];试图展示:-(UICollectionReu

ios - 检测 iOS UICollectionCell 何时离开屏幕

我有一个UICollectionView将图片作为其数据存储中的元素。我只想在相应的UICollectionViewCell当前显示在屏幕上时才将高分辨率图片加载到元素中。稍后,当UICollectionViewCell离开屏幕时,我想将元素的UIImage返回到低分辨率版本。我的问题是,如何检测UICollectionViewCell何时离开屏幕?(我尝试使用prepareForReuse方法,但我无法预测它何时会被调用)。我目前正在使用scrollViewDidScroll中的一段代码,每次View滚动时,我都会检查self.collectionView.visibleCells以

ios - 检测 iOS UICollectionCell 何时离开屏幕

我有一个UICollectionView将图片作为其数据存储中的元素。我只想在相应的UICollectionViewCell当前显示在屏幕上时才将高分辨率图片加载到元素中。稍后,当UICollectionViewCell离开屏幕时,我想将元素的UIImage返回到低分辨率版本。我的问题是,如何检测UICollectionViewCell何时离开屏幕?(我尝试使用prepareForReuse方法,但我无法预测它何时会被调用)。我目前正在使用scrollViewDidScroll中的一段代码,每次View滚动时,我都会检查self.collectionView.visibleCells以