Both Vertical and Horizontal Scroll Direction in UICollectionView

时间:2016-04-07 10:50:51

标签: ios objective-c xcode uicollectionview

Im stuck with the problem to use both vertical and horizontal scroll direction in a UICollectionView in the same UIViewController.

What I've done so far is first a UICollectionView. In top of the UICollectionView I've got a Collection Reusable View. My solution is to implement an other UICollectionView inside of the reusable view but got errors when running the project.

*** Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'the view returned from -collectionView:viewForSupplementaryElementOfKind:atIndexPath (UICollectionElementKindSectionHeader,<NSIndexPath: 0xc000000000000016> {length = 2, path = 0 - 0}) was not retrieved by calling -dequeueReusableSupplementaryViewOfKind:withReuseIdentifier:forIndexPath: or is nil ((null))

So Im actually handling two different CollectionViews in one UIViewController in the same Delegate and Datasource methods.

It is a better approach to build it with a UITablewView? Than add the collectionviews to different UITableViewCells? Or better to start with an UIScrollView and then add two different UICollectionViews to the scrollview?

enter image description here

1 个答案:

答案 0 :(得分:0)

AFTabledCollectionView

参考上面的示例代码

在此示例代码中。 UITableView就在那里,UITableviewCell包含UICollectionView(水平方向)。

以上示例代码中有关您的问题的更多细节

选择一个&#39; UITableView&#39;有2节。它的第一部分将有&#39; UICollectionView&#39;第二部分有&#39; UICollectionView&#39;。