[英]UICollectionView layout crashes on iPad, but works fine on iPhone
UICollection view layout crasing in ipad, but works fine iphone. UICollection视图布局在ipad中令人生畏,但可以在iphone上正常工作。 Will we have to manage UICollection view layout for ipad differently than iphone?
我们是否需要以不同于iPhone的方式管理iPad的UICollection视图布局?
My code : 我的代码:
-(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);
}
*** Terminating app due to uncaught exception 'NSRangeException', reason: '*** -[__NSArrayM objectAtIndex:]: index 5 beyond bounds [0 .. 4]' ***
This clearly says, that you trying to access element, which is beyond array bounds. 这清楚地表明,您正在尝试访问超出数组范围的元素。 Check next:
下一步检查:
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.