dequeueReusableSupplementaryViewOfKind崩溃在ios 7.1 – 索引0超出界限为空数组
具有2个部分的收集视图。
section 1: rows: 0 section 2: rows: 20
有像以下注册的网友:
[self.collectionView registerNib:[UINib nibWithNibName:@"MissionDetailHeader" bundle:nil] forSupplementaryViewOfKind:UICollectionElementKindSectionHeader withReuseIdentifier:@"MissionDetailHeader"]; [self.collectionView registerNib:[UINib nibWithNibName:@"MissionDetailHeaderPic" bundle:nil] forSupplementaryViewOfKind:UICollectionElementKindSectionHeader withReuseIdentifier:@"MissionDetailHeaderPic"];
在ios8上完美工作 – 但在7.1上它总是在dequeueReusableSupplementaryViewOfKind
上崩溃:
- (UICollectionReusableView*)collectionView:(UICollectionView*)cv viewForSupplementaryElementOfKind:(NSString*)kind atIndexPath:(NSIndexPath*)indexPath { UICollectionReusableView* header; NSLog(@"LOAD SECT: %@", indexPath); if (indexPath.section == 0) { header = [collectionView dequeueReusableSupplementaryViewOfKind:kind withReuseIdentifier:@"MissionDetailHeaderPic" forIndexPath:indexPath]; } else { header = [collectionView dequeueReusableSupplementaryViewOfKind:kind withReuseIdentifier:@"MissionDetailHeader" forIndexPath:indexPath]; } return header; }
堆栈跟踪:
*** Terminating app due to uncaught exception 'NSRangeException', reason: '*** -[__NSArrayM objectAtIndex:]: index 0 beyond bounds for empty array' *** First throw call stack: ( 0 CoreFoundation 0x047c61e4 __exceptionPreprocess + 180 1 libobjc.A.dylib 0x009f98e5 objc_exception_throw + 44 2 CoreFoundation 0x047673f6 -[__NSArrayM objectAtIndex:] + 246 3 UIKit 0x03d18750 -[UICollectionViewFlowLayout(Internal) _frameForHeaderInSection:usingData:] + 61 4 UIKit 0x03d14afa -[UICollectionViewFlowLayout layoutAttributesForHeaderInSection:usingData:] + 61 5 UIKit 0x03d15687 -[UICollectionViewFlowLayout layoutAttributesForSupplementaryViewOfKind:atIndexPath:] + 192 6 UIKit 0x03d2f02a -[UICollectionViewData layoutAttributesForSupplementaryElementOfKind:atIndexPath:] + 363 7 UIKit 0x03cf9764 -[UICollectionView _dequeueReusableViewOfKind:withIdentifier:forIndexPath:viewCategory:] + 242 8 UIKit 0x03cfa00a -[UICollectionView dequeueReusableSupplementaryViewOfKind:withReuseIdentifier:forIndexPath:] + 239 9 fivexfive 0x00102e33 -[MissionDetailViewController collectionView:viewForSupplementaryElementOfKind:atIndexPath:] + 243 10 UIKit 0x03cec099 -[UICollectionView _createPreparedSupplementaryViewForElementOfKind:atIndexPath:withLayoutAttributes:applyAttributes:] + 480 11 UIKit 0x03ced775 -[UICollectionView _updateVisibleCellsNow:] + 4730 12 UIKit 0x03cf165f -[UICollectionView layoutSubviews] + 265 13 UIKit 0x03714964 -[UIView(CALayerDelegate) layoutSublayersOfLayer:] + 355 14 libobjc.A.dylib 0x00a0b82b -[NSObject performSelector:withObject:] + 70 15 QuartzCore 0x0342b45a -[CALayer layoutSublayers] + 148 16 QuartzCore 0x0341f244 _ZN2CA5Layer16layout_if_neededEPNS_11TransactionE + 380
已经search了所有和谷歌search – 找不到任何提示/提示如何追查错误。
关于helmut
好的回答我自己:D
去除
[self.stretchyLayout setSectionInset:UIEdgeInsetsMake(8, 8, 0, 8)];
所有对setSectionInset的调用 – 固定在ios7上
- MyApp“具有超出允许时间的活动断言”崩溃 – CoreLocationRegistration和CoreLocationBackgroundClient
- 当我尝试呈现一个UIPopoverController时崩溃/ SIGABRT
- NSDictionary:只为抽象类定义的方法。 我的应用程序崩溃
- 苹果拒绝我的应用程序,由于崩溃,无法重现
- com.apple.NSURLSession-work EXC_BAD_ACCESS崩溃debugging
- _GSRegisterPurpleNamedPortInPrivateNamespace – app store崩溃(附代码)
- 区分一个iPhone应用程序崩溃和被杀死
- 如何在iOS中高效地使用图像做animation
- 在从ios应用程序注册QuickBlox中的新用户时终止应用程序