UICollectionViewController を使用する iOS 6 用に作成されたアプリがあります。アプリは正常に動作しますが、Xcode 5 でコンパイルしようとすると、以下のエラーが発生します。
キャッチされていない例外 'NSInternalInconsistencyException' が原因でアプリを終了しています。理由: 'setCollectionViewLayout でレイアウトを nil にすることはできません:'...
このソリューションを使用しようとしましたが、同じエラーが発生し続けます。何か案は?
CollectionViewLayout *layout = [[CollectionViewLayout alloc] init];
self.collectionView = [[UICollectionView alloc] initWithFrame:CGRectZero collectionViewLayout:layout];
[self.collectionView registerClass:[Cell class] forCellWithReuseIdentifier:ItemIdentifier];
[self.collectionView registerClass:[HeaderCollectionReusableView class] forSupplementaryViewOfKind:UICollectionElementKindSectionHeader withReuseIdentifier:@"HeaderView"];
self.collectionLayout.headerReferenceSize = CGSizeMake(0, 50);
self.collectionView.delegate = self;
self.collectionView.dataSource = self;
self.collectionView.indicatorStyle = UIScrollViewIndicatorStyleWhite;
self.collectionLayout.scrollDirection = UICollectionViewScrollDirectionVertical;
//スタックトレース
2013-10-01 14:15:37.140 MemberCatalog[10841:a0b] *** Assertion failure in -[UICollectionView setCollectionViewLayout:], /SourceCache/UIKit_Sim/UIKit-2903.2/UICollectionView.m:2001
2013-10-01 14:15:37.186 MemberCatalog[10841:a0b] Uncaught exception: NSInternalInconsistencyException
Reason: layout cannot be nil in setCollectionViewLayout:
User Info: (null)
Call Stack: (
0 CoreFoundation 0x031e75e4 __exceptionPreprocess + 180
1 libobjc.A.dylib 0x02c548b6 objc_exception_throw + 44
2 CoreFoundation 0x031e7448 +[NSException raise:format:arguments:] + 136
3 Foundation 0x0029923e -[NSAssertionHandler handleFailureInMethod:object:file:lineNumber:description:] + 116
4 UIKit 0x00cdeba3 -[UICollectionView setCollectionViewLayout:] + 156
5 UIKit 0x00cfcd7b -[UICollectionViewControllerWrapperView didMoveToSuperview] + 462
6 UIKit 0x007261a6 __45-[UIView(Hierarchy) _postMovedFromSuperview:]_block_invoke + 472
7 UIKit 0x00725ef8 -[UIView(Hierarchy) _postMovedFromSuperview:] + 260
8 UIKit 0x00731031 -[UIView(Internal) _addSubview:positioned:relativeTo:] + 1847
9 UIKit 0x00724521 -[UIView(Hierarchy) addSubview:] + 56
10 UIKit 0x007d66eb +[UIViewControllerWrapperView wrapperViewForView:wrapperFrame:viewFrame:] + 382
11 UIKit 0x0080c867 -[UITabBarController _wrapperViewForViewController:] + 221
12 UIKit 0x00813a60 -[UITabBarController transitionFromViewController:toViewController:transition:shouldSetSelected:] + 441
13 UIKit 0x00813262 -[UITabBarController transitionFromViewController:toViewController:] + 63
14 UIKit 0x0080f64b -[UITabBarController _setSelectedViewController:] + 279
15 UIKit 0x0080f470 -[UITabBarController setSelectedIndex:] + 261
16 MemberCatalog 0x000aa9f8 -[MainViewController updateTabBar:] + 584
17 MemberCatalog 0x000ab872 -[MainViewController showCategory::] + 3538
18 MemberCatalog 0x000abe30 -[MainViewController menuButtonTap:] + 1296
19 libobjc.A.dylib 0x02c66874 -[NSObject performSelector:withObject:withObject:] + 77
20 UIKit 0x006cac8c -[UIApplication sendAction:to:from:forEvent:] + 108
21 UIKit 0x006cac18 -[UIApplication sendAction:toTarget:fromSender:forEvent:] + 61
22 UIKit 0x007c26d9 -[UIControl sendAction:to:forEvent:] + 66
23 UIKit 0x007c2a9c -[UIControl _sendActionsForEvents:withEvent:] + 577
24 UIKit 0x007c1d4b -[UIControl touchesEnded:withEvent:] + 641
25 UIKit 0x007080cd -[UIWindow _sendTouchesForEvent:] + 852
26 UIKit 0x00708d34 -[UIWindow sendEvent:] + 1232
27 UIKit 0x006dca36 -[UIApplication sendEvent:] + 242
28 UIKit 0x006c6d9f _UIApplicationHandleEventQueue + 11421
29 CoreFoundation 0x031708af __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE0_PERFORM_FUNCTION__ + 15
30 CoreFoundation 0x0317023b __CFRunLoopDoSources0 + 235
31 CoreFoundation 0x0318d30e __CFRunLoopRun + 910
32 CoreFoundation 0x0318cb33 CFRunLoopRunSpecific + 467
33 CoreFoundation 0x0318c94b CFRunLoopRunInMode + 123
34 GraphicsServices 0x03c6a9d7 GSEventRunModal + 192
35 GraphicsServices 0x03c6a7fe GSEventRun + 104
36 UIKit 0x006c994b UIApplicationMain + 1225
37 MemberCatalog 0x000033e6 main + 134
38 libdyld.dylib 0x0395a725 start + 0