草庐IT

CollectionView

全部标签

ios - 在 collectionview 中选择和取消选择行时出错

我在collectionView中快速选择和取消选择行时遇到问题。我有一张map,在它上面我有一个水平的collectionView,我可以选择我想看到的内容。funccollectionView(collectionView:UICollectionView,didSelectItemAtIndexPathindexPath:NSIndexPath){letselectedCell:UICollectionViewCell=collectionView.cellForItemAtIndexPath(indexPath)!selectedCell.contentView.backgro

ios - 在一个 UICollectionView 中实现两个 CollectionView 布局

这里已经有人问过这个问题(CanwesetdifferentflowlayoutindifferentsectionswithinaUICollectionView?).....但没有人回应,我的声誉太低,无法发表评论和顶帖。我正在使用collectionView来模拟tableView,前几个单元格横跨屏幕宽度。但是我希望创建第二个部分并将布局更改为更多的瀑布效果,类似于Pinterest。我已经为两个部分制作了布局,我只是想知道是否有人对如何同时实现两个布局有任何想法。这可以做到吗?谢谢 最佳答案 您将创建两个Collectio

ios - 如何在 CollectionView 中创建这个布局

您好,我想知道我们如何在collectionview中实现此布局,我们需要放置图像或调整单元格大小我点击了此链接https://www.raywenderlich.com/107439/uicollectionview-custom-layout-tutorial-pinterest但在此他们传递了项目的图像大小,因此根据图像大小显示了不同大小的项目,但我喜欢在图像中像这样修复布局任何帮助将不胜感激提前致谢 最佳答案 使用this出色的控制来实现您的目标。使用起来非常简单。将以下文件添加到您的项目customLayout.hcust

ios - swift:CollectionView 单元格大小

我有collectionView对superview的约束。我想获得iPhoneX的结果:但是我明白了:如何解决?代码:funcnumberOfSections(incollectionView:UICollectionView)->Int{return4}funccollectionView(_collectionView:UICollectionView,numberOfItemsInSectionsection:Int)->Int{return3}funccollectionView(_collectionView:UICollectionView,layoutcollectio

IOS - SWIFT - CollectionView -> ImageView 加载 URL 图片

我有一个CollectionView,其中包含应从网络加载的图像。URL在字符串数组中,在collectionView单元格中是imageView。我找到了这段代码:funccollectionView(collectionView:UICollectionView,cellForItemAtIndexPathindexPath:NSIndexPath)->UICollectionViewCell{varcell=collectionView.dequeueReusableCellWithReuseIdentifier("cell",forIndexPath:indexPath)as!

swift - 从 collectionView 到 Detail

我将数据从一个CollectionViewController传递到一个细节ViewController。一切似乎都在工作,但是"prepareForSegue发生在"didSelectItemAtIndexPath"之前,所以它传递的是我上次选择的项目的数据,而不是我现在选择的项目的数据立即选择。这是我对collectionViewController的错误代码varcellSelected:Int=0overridefunccollectionView(collectionView:UICollectionView,didSelectItemAtIndexPathindexPath

ios - 如何在 swift 3 中以编程方式选择 collectionView 中的单元格?

我是swift的新手,在以编程方式选择collectionView中的collectionview单元格时遇到了问题。我只找到了tableview的说明,但在尝试实现它时遇到了错误。letindexPath=IndexPath(row:0,section:0)appsCollectionView.selectItem(at:indexPath,animated:false,scrollPosition:.bottom)appsCollectionView.delegate?.collectionView!(appsCollectionView,didSelectItemAt:index

iOS 如何知道按下了哪个按钮 CollectionView 与自定义委托(delegate)

所以我在collectionview中有一个单元格,里面有3个按钮。为了使用这些按钮触发代码,我实现了一个自定义委托(delegate)。现在正在触发代码,但我不知道代码是从哪个单元格触发的。我怎样才能最好地实现这一点?这是我的一些代码。协议(protocol):protocolOverViewDelegate{funcregisterButtonClicked()funcevaluateButtonClicked()funcoverviewButtonClicked()}cellForItemAt:funccollectionView(_collectionView:UICollec

ios - 如何在 tableview 单元格内的 collectionview 单元格的按钮单击上获取索引

我在tableView单元格中嵌入了一个collectionView。CollectionView有多个项目,其中包含按钮。CollectionView数据源和委托(delegate)在UITableViewCell中设置。为此,我必须根据该按钮选择执行一些操作,我需要知道collectionViewcellindexPath和tableViewcellindexPath。但无法弄清楚,如何实现这一目标。尝试使用委托(delegate),但不知道如何在委托(delegate)方法中获取collectionView引用。CollectionView单元格protocolSelectedI

swift - CollectionView 部分

我有一个collectionview,我希望它有n个部分,每个部分有10个单元格,我的问题是:也许n等于35,在这种情况下,我想显示3个部分,有10个单元格和最后一节只有五个。 最佳答案 如果数组计数是35returncount/10如果count%10是0elsereturncount/10+1innumberOfSections方法在numberOfItemsInSection方法中,将当前部分乘以10,然后从计数中减去。返回10的最小值或减去的值在cellForItemAt方法中,section乘以10并添加row以获得数组索