在UICollectionView Xcode中添加子视图

use*_*641 3 xcode objective-c ios uicollectionview

我在UICollectionView里面添加了我的设备照片UICollectionViewCell,现在我想在我的内部创建子视图UICollectionView.请告诉我如何添加subview内部UICollectionViews.需要任何代码或链接.

Ama*_*mar 17

添加子视图非常简单,

//Create subview    
UIView *subview = [[UIView alloc] initWithFrame:CGRectMake(0, 0, self.collectionView.frame.size.width, 20)];
//Add
[collectionView addSubview:subview];
//Bring to front so that it does not get hidden by cells
[collectionView bringSubviewToFront:subview];
//This will shift collectionView content down by 20px at top
[collectionView setContentInset:UIEdgeInsetsMake(subview.frame.size.height, 0, 0, 0)];
Run Code Online (Sandbox Code Playgroud)

上面的代码将在collectionView的顶部添加一个子视图.这是你想要的?如果没有,请在您的问题中提供更多细节.