UICollection视图布局在ipad中崩溃,但工作正常iphone。 我们是否必须以不同于iphone的方式管理ipad的UICollection视图布局?
我的代码:
-(void)reloadData {
if(collectionData!= nil)
{
collectionData = nil;
}
[self.collectionView reloadData];
}
-(void)setCollectionView {
if(self.collectionView == nil) {
// self.collectionView = (UICollectionView *)[self.view viewWithTag:_wallCollectionView_tag];
self.collectionView.dataSource = self;
self.collectionView.delegate = self;
self.collectionView.userInteractionEnabled = YES;
}
}
`enter code here`- (NSInteger)numberOfSectionsInCollectionView:(UICollectionView *)collectionView
{printf("\n = %s",__FUNCTION__);
return 1;
}
- (NSInteger)collectionView:(UICollectionView *)collectionView numberOfItemsInSection:(NSInteger)section
{
return [collectionData count];
}
- (CGSize)collectionView:(UICollectionView *)collectionView
layout:(UICollectionViewLayout*)collectionViewLayout
sizeForItemAtIndexPath:(NSIndexPath *)indexPath {
if ( [ [ UIScreen mainScreen ] bounds ].size.width > 320) {
return CGSizeMake(118, 118);
}
return CGSizeMake(100, 100);
}
答案 0 :(得分:1)
*** Terminating app due to uncaught exception 'NSRangeException', reason: '*** -[__NSArrayM objectAtIndex:]: index 5 beyond bounds [0 .. 4]' ***
这清楚地说,你试图访问超出数组边界的元素。检查下一个: