Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/objective-c/26.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/cmake/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Objective c UICollectionView cellForItemAtIndexPath:在iOS 7中未调用_Objective C_Ios7_Xcode5 - Fatal编程技术网

Objective c UICollectionView cellForItemAtIndexPath:在iOS 7中未调用

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

因此,该代码在iOS 6中运行良好。但是,当我在iOS 7设备上运行它时,collectionView不会填充项目,并且保持为空。我发现:

(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。