UICollection视图布局在ipad中擦除,但工作得很好iphone。 我们是否需要为iPhone管理与iPhone不同的UICollection视图布局?UICollectionView布局在iPad上崩溃,但在iPhone上正常工作
我的代码:
-(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);
}
你有没有碰撞记录? – iOSdev
2015年5月6日18:21:53.777 FlrtAlertVariation [39992:1010801]负或零个大小不是在流布局支持 的CollectionView:布局:sizeForItemAtIndexPath:] 和 [_UIFlowLayoutItem setItemFrame:]:消息发送到释放实例0x7fcc35296310 和 2015-05-06 16:14:56.036 FlrtAlertVariation [37736:957131] ***由于未捕获异常'NSRangeException',原因:'*** - [__ NSArrayM objectAtIndex:]:index 5越界[0..4]' ***第一次掷出呼叫堆栈: –
@RavinderKumar更新你的问题,不要在评论中发布异常。 – rmaddy