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