我正在尝试初始化集合视图,显示其不兼容的类型。我写了下面的代码
UICollectionView * collCobj = [[UICollectionView alloc]initWithFrame:CGRectMake(0, 260, 320, 230) collectionViewLayout:UICollectionViewScrollPositionLeft];
答案 0 :(得分:0)
更改
uicollectionview collCobj
到
UICollectionView *collCobj
您可能会错过*
并错过了集合视图类名称。
修改
给出适当的参数作为布局。您正在传递UICollectionViewScrollPositionLeft
作为错误的布局对象。检查一下
UICollectionViewFlowLayout *layout = [[UICollectionViewFlowLayout alloc]init];
UICollectionView *collCobj = [[UICollectionView alloc]initWithFrame:CGRectMake(0, 260, 320, 230) collectionViewLayout:layout];
答案 1 :(得分:0)
Initialize collection in proper manner
UICollectionViewFlowLayout *layout=[[UICollectionViewFlowLayout alloc] init];
collectionViewObj=[[UICollectionView alloc] initWithFrame:CGRectMake(0, 0 , 320, 250) collectionViewLayout:layout];
[collectionViewObj setDataSource:self];
[collectionViewObj setDelegate:self];
[collectionViewObj registerClass:[Cell class] forCellWithReuseIdentifier:@"cellIdentifier"];
[self.view addSubview:collectionViewObj];