Reputation: 848
UICollection view layout crasing in ipad, but works fine iphone. Will we have to manage UICollection view layout for ipad differently than iphone?
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);
}
Upvotes: 0
Views: 1544
Reputation: 285
*** 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:
Upvotes: 1