Objective c UICollectionView cellForItemAtIndexPath:在iOS 7中未调用
因此,该代码在iOS 6中运行良好。但是,当我在iOS 7设备上运行它时,collectionView不会填充项目,并且保持为空。我发现:Objective c UICollectionView cellForItemAtIndexPath:在iOS 7中未调用,objective-c,ios7,xcode5,Objective C,Ios7,Xcode5,因此,该代码在iOS 6中运行良好。但是,当我在iOS 7设备上运行它时,collectionView不会填充项目,并且保持为空。我发现: (UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath 甚至没有人打电话 下面是我创建collectionView的代码 ItemOptionListCollectio
(UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath
甚至没有人打电话
下面是我创建collectionView的代码
ItemOptionListCollectionViewController *mv1 =[[ItemOptionListCollectionViewController alloc] initWithNibName:@"GridOpcija" bundle:nil];
[mv1.collectionView registerClass:[OptionListCollectionViewCell class] forCellWithReuseIdentifier:@"CellZaOpcije"];
[mv1.collectionView setDelegate:mv1];
mv1.collectionView.dataSource= mv1;
[mv1 insertListAsDataSource:[ol optionListItems]];
CGFloat scrollHeight = 0;
scrollHeight= ([ol.optionListItems count])*40;
mv1.view.frame = CGRectMake(0, height, modal.scrollView.frame.size.width,scrollHeight);
height +=mv1.view.frame.size.height;
[modal.scrollView addSubview:mv1.view];
ItemOptionListCollectionViewController非常简单,只有collectionView:cellForItemAtIndexPath:
有什么想法吗?mv1.collectionView在您设置其数据源时的值是多少?您是否检查了mv.collectionView是否实际引用了一个对象并且不是零(视图是否实际已加载)?试着在视图控制器中移动将数据源和委托设置为viewDidLoad的代码。。。只是猜测一下,当我打印mv1.collectionView时,我得到了register类上方的
集合视图布局:
。我还有self.collectionView.delegate=self代码>和self.collectionView.dataSource=self代码>在viewDidLoad for ItemOptionListCollectionViewController中。你已经弄明白了吗?不,不幸的是,我花了很多时间试图弄明白,我意识到重新编码该部分会容易得多,因为它工作完美。我猜有些维度不匹配,因为iOS 7限制性更强,所以它不想显示collectionView。