草庐IT

UiCollectionView

全部标签

swift - UICollectionViewFlowLayout estimatedItemSize 不适用于 iOS12,但它适用于 iOS 11。*

对于我们使用的UICollectionView的动态高度单元格,ifletlayout=self.collectionViewLayoutas?UICollectionViewFlowLayout{layout.estimatedItemSize=UICollectionViewFlowLayoutAutomaticSize}在高度和宽度的适当约束下,它适用于iOS11.*版本,但它会中断并且不会使单元格在iOS12.0上动态 最佳答案 在我的例子中,我通过向单元格的contentView显式添加以下约束来解决这个问题。classC

swift - UICollectionViewFlowLayout estimatedItemSize 不适用于 iOS12,但它适用于 iOS 11。*

对于我们使用的UICollectionView的动态高度单元格,ifletlayout=self.collectionViewLayoutas?UICollectionViewFlowLayout{layout.estimatedItemSize=UICollectionViewFlowLayoutAutomaticSize}在高度和宽度的适当约束下,它适用于iOS11.*版本,但它会中断并且不会使单元格在iOS12.0上动态 最佳答案 在我的例子中,我通过向单元格的contentView显式添加以下约束来解决这个问题。classC

swift - 如何以编程方式创建 UICollectionViewCell

我正在尝试以编程方式创建UICollectionView。我需要在单元格内添加标签,所以我创建了CollectionViewCell类。这是类:importUIKitclassMyCollectionViewCell:UICollectionViewCell{overrideinit(frame:CGRect){super.init(frame:frame)}requiredinit?(coderaDecoder:NSCoder){fatalError("init(coder:)hasnotbeenimplemented")}}这是collectionView的实现类:importUI

swift - 如何以编程方式创建 UICollectionViewCell

我正在尝试以编程方式创建UICollectionView。我需要在单元格内添加标签,所以我创建了CollectionViewCell类。这是类:importUIKitclassMyCollectionViewCell:UICollectionViewCell{overrideinit(frame:CGRect){super.init(frame:frame)}requiredinit?(coderaDecoder:NSCoder){fatalError("init(coder:)hasnotbeenimplemented")}}这是collectionView的实现类:importUI

ios - 如何实现横向无限滚动的UICollectionView?

我想实现水平无限滚动的UICollectionView? 最佳答案 如果你的数据是静态的并且你想要一种循环行为,你可以这样做:vardataSource=["item0","item1","item2"]funccollectionView(collectionView:UICollectionView,numberOfItemsInSectionsection:Int)->Int{returnInt.max//insteadofreturnindataSource.count}funccollectionView(collecti

ios - 如何实现横向无限滚动的UICollectionView?

我想实现水平无限滚动的UICollectionView? 最佳答案 如果你的数据是静态的并且你想要一种循环行为,你可以这样做:vardataSource=["item0","item1","item2"]funccollectionView(collectionView:UICollectionView,numberOfItemsInSectionsection:Int)->Int{returnInt.max//insteadofreturnindataSource.count}funccollectionView(collecti

ios - 在 ViewController 的 UICollectionView 中拉动刷新

我在UICollectionViewController中使用了以下代码overridefuncviewDidLoad(){self.collectionView!.alwaysBounceVertical=trueletrefresher=UIRefreshControl()refresher.addTarget(self,action:"refreshStream",forControlEvents:.ValueChanged)refreshControl=refreshercollectionView!.addSubview(refreshControl!)}funcrefres

ios - 在 ViewController 的 UICollectionView 中拉动刷新

我在UICollectionViewController中使用了以下代码overridefuncviewDidLoad(){self.collectionView!.alwaysBounceVertical=trueletrefresher=UIRefreshControl()refresher.addTarget(self,action:"refreshStream",forControlEvents:.ValueChanged)refreshControl=refreshercollectionView!.addSubview(refreshControl!)}funcrefres

ios - 如何使用 swift 在 UICollectionView 单元格中加载自定义单元格(xib)

我使用Swift创建了一个小型示例项目。我创建了一个“MyCustomView”作为xib,其中包含标签、按钮和imageView,如下面的代码所示:importUIKit@IBDesignableclassMyCustomView:UIView{@IBOutletweakvarlblName:UILabel!@IBOutletweakvarbtnClick:UIButton!@IBOutletweakvarmyImageView:UIImageView!varview:UIView!@IBInspectablevarmytitleLabelText:String?{get{retur

ios - 如何使用 swift 在 UICollectionView 单元格中加载自定义单元格(xib)

我使用Swift创建了一个小型示例项目。我创建了一个“MyCustomView”作为xib,其中包含标签、按钮和imageView,如下面的代码所示:importUIKit@IBDesignableclassMyCustomView:UIView{@IBOutletweakvarlblName:UILabel!@IBOutletweakvarbtnClick:UIButton!@IBOutletweakvarmyImageView:UIImageView!varview:UIView!@IBInspectablevarmytitleLabelText:String?{get{retur