草庐IT

collectionViews

全部标签

ios - 如何重新加载 tableviewcell 中的 collectionview

我在tableViewCell中有一个collectionView例如:信用:HowtouseStoryBoardquickbuildacollectionViewinsideUITableViewCell我想在更新信息时重新加载collectionView。我已经在collectionView的cellForItemAtIndexPath中放置了一个print来测试它是否被调用,但实际上没有。如何让collectionView重新加载? 最佳答案 我知道怎么做了!在我的tableViewCell类中,我只需要将collection

swift - 如何从 collectionview 重新加载部分

我试图通过didSelect方法从collectionview中删除一个单元格。删除数据效果很好。但是我得到这个:reason:'Invalidupdate:invalidnumberofsections.Thenumberofsectionscontainedinthecollectionviewaftertheupdate(1)mustbeequaltothenumberofsectionscontainedinthecollectionviewbeforetheupdate(2),plusorminusthenumberofsectionsinsertedordeleted(0i

ios - CollectionView 导航栏下的内容

我希望collectionView的内容从屏幕的最顶部(状态栏的顶部)开始,因为我有透明的导航栏,我想避免魔数(MagicNumber),它应该与iPhoneX和其他iPhone。我试过什么?collectionView.contentInset=UIEdgeInsets(上:-64,左:0,下:0,右:0)但这不是一个优雅的解决方案,并且对于iPhoneX来说是不正确的,需要增加inset任何干净的解决方案?目标iOS10和11 最佳答案 将此添加到包含UICollectionView的UIViewController中,以防止C

swift - prepareForSegue collectionView indexPath 使用 swift

我找不到任何好的例子来使用swift做我想做的事,所以我允许自己问这个问题。我使用collectionView来显示PFObject,我想使用prepareForSegue将显示的单元格数据发送到第二个Controller。此时,我正在努力使这部分代码正常工作:overridefuncprepareForSegue(segue:UIStoryboardSegue,sender:AnyObject?){if(segue.identifier=="goto_answerquestion"){varindexpath:NSIndexPath=self.collectionView.index

ios - 如何将刷新控件添加到 View Controller 中的水平 collectionview?

我目前有:refresher=UIRefreshControl()refresher.attributedTitle=NSAttributedString(string:"Pulltorefresh")refresher.addTarget(self,action:"refresh:",forControlEvents:UIControlEvents.ValueChanged)self.postsView.addSubview(refresher)在包含CollectionView的ViewController的viewdidload()中。与collectionview交互并让自定义

ios - 默认情况下在 collectionView 中滚动时选择单元格

我有一个自定义的CollectionView布局,它似乎会产生一些错误。或者也许我错过了什么。布局看起来像这样,来自here:我的问题是我无法将居中单元格的indexPath传递给粉红色按钮,调用centerCellIndexPath会产生nil。我还尝试在布局本身中预选单元格,如下所示:overrideopenfunctargetContentOffset(forProposedContentOffsetproposedContentOffset:CGPoint,withScrollingVelocityvelocity:CGPoint)->CGPoint{//item'ssetup

ios - collectionView 页脚未显示

我已经检查了sectionfooter,如下面的屏幕截图所示。我还实现了dataSource方法:overridefunccollectionView(collectionView:UICollectionView,viewForSupplementaryElementOfKindkind:String,atIndexPathindexPath:NSIndexPath)->UICollectionReusableView{ifkind==UICollectionElementKindSectionHeader{varheader=collectionView.dequeueReusab

ios - 使用自定义 FlowLayout (Swift) 时将 HeaderView 添加到 CollectionView

我已经实现了一个自定义的FlowLayout子类,这显然阻止了我通过storyboard添加一个headerView(复选框是走了)。有没有其他方法可以使用storyboards来做到这一点?有一些关于如何以编程方式添加headerView的答案,但它们在objective-C中,我如何使用Swift添加一个>?下面没有生成标题View,我不明白为什么?CollectionViewController{overridefuncviewDidLoad(){super.viewDidLoad()//SetupHeaderself.collectionView!.registerClass(

ios - 如何通过 indexPath 在水平 collectionView 中动态添加 View /图层

我正在制作一个带有水平collectionView的时间轴,其中对于每个时间block(一个月),我都有一个单元格,其中包含每天不同颜色的UIViews。有些月份添加了30个View,有些是31个,有些是28个。我无法将View动态添加到每个单元格,以免它们被复制或添加到错误的单元格。为此,我创建了此时间轴的简化版本,其中每个月仅动态添加1个图层/View-然后我将尝试解决添加可变数量的View/图层的问题。我将这个项目作为我正在谈论的最简单的例子:https://github.com/AlexMarshall12/testTimeline-iOS这是ViewController.sw

swift - 无法使用全局变量访问 collectionView 单元格变量

在这里,我创建了一个collectionView单元格变量来访问这两个对象。但是无法访问单元格变量里面的对象funccollectionView(_collectionView:UICollectionView,cellForItemAtindexPath:IndexPath)->UICollectionViewCell{varcell:UICollectionViewCell!ifcollectionView==collectionView1{cell=collectionView.dequeueReusableCell(withReuseIdentifier:"cellAttach