您的位置:首页 > 产品设计 > UI/UE

UICollectionViewController的创建

2014-11-09 10:30 218 查看
1. 在开发collection view的时候遇到的问题,因为页面在storyboard中,所以直接在storyboard里设置它的layout,和cell的size等属性。

2. 另外,UICollectionViewController控制器本来有四个init方法:

- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil {}

- (id)initWithCollectionViewLayout:(UICollectionViewLayout *)layout {}

- (id)initWithCoder:(NSCoder *)aDecoder {}

- (id)init {}

但是由于是在storyboard里直接定义的控制器,所以代码里只有initWithCoder:(NSCoder *)aDecoder 方法被调用,另外3个没有被调用。

3. 给它注册了定义的标题栏类MCMonthHeaderView, 没有使用xib文件.

[self.collectionView registerClass:[MCMonthHeaderView class] forSupplementaryViewOfKind:UICollectionElementKindSectionHeader withReuseIdentifier:@"monthHeader"];

在MCMonthHeaderView类继承了UICollectionViewReusableView类,它的初始化方法也有三个,

- (id)initWithFrame:(CGRect)frame{}

- (id)initWithCoder:(NSCoder *)aDecoder{}

- (id)init{}

发现只有initWithFrame:方法是被调用的,其他两个方法不会被调用.
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: