Ich habe meine Ansicht nach Code, aber zwei UICollectionViews erstellt. Also erstellt sie im Storyboard und muss sie nach Code suchen. Diese ist, wie ich es tat:Suche nach Storyboard-Ansichten nach Code
TopProducts = UICollectionView(frame: CGRect(x: 8, y: scrollViewHeight + 166, width: viewWidth - 8, height: 120))
contentScrollView.addSubview(TopProducts)
App stürzt ab und dieser Fehler zeigt in der Konsole nach oben:
* App beenden aufgrund nicht abgefangene Ausnahme 'NSInvalidArgumentException' Grund: ‚UICollectionView muss sein mit einem nicht-Null-Layout-Parameter‘initialisiert * erster Wurf Call-Stack: ( 0 Corefoundation 0x000000010271526b exceptionPreprocess + 171 1 libobjc.A.dylib 0x0 00000010160af41 objc_exception_throw + 48 2 Corefoundation 0x0000000102789ba5 + [NSException Erhöhung: Format:] + 197 3 UIKit 0x0000000105d14a39 - [UICollectionView Initwithframe: collectionViewLayout:] + 81 4 UIKit 0x0000000105d149e2 - [UICollectionView Initwithframe:] + 58 5 JahanCo Katalog 0x0000000100747bfd _T0So16UICollectionViewCABSC6CGRectV5frame_tcfcTO + 77 6 JahanCo Katalog 0x0000000100744f24 _T0So16UICollectionViewCABSC6CGRectV5frame_tcfC + 100 7 JahanCo Katalog 0x00000001007446f0 _T015JahanCo_Catalog9SlideViewC11viewDidLoadyyF + 9936 8 JahanCo Katalog 0x0000000100744fa4 _T015JahanCo_Catalog9SlideViewC11viewDidLoadyyFTo + 36 9 UIKit 0x000000010542fd93 - [UIViewController loadViewI fRequired] + 1235 10 UIKit 0x0000000105476cd4 - [UINavigationController _updateScrollViewFromViewController: toViewController:] + 68 11 UIKit 0x0000000105477010 - [UINavigationController _startTransition: fromViewController: toViewController:] + 153 12 UIKit 0x0000000105478127 - [UINavigationController _startDeferredTransitionIfNeeded:] + 841 13 UIKit 0x0000000105479388 - [UINavigationController __viewWillLayoutSubviews] + 115 14 UIKit 0x00000001056c26d9 - [UILayoutContainerView layoutSubviews] + 231 15 UIKit 0x000000010536321e - [UIView (CALayerDelegate) layoutSublayersOfLayer:] + 1331 16 Quartz 0x0000000103375c92 - [CALayer layoutSublayers] + 153 17 Quartz 0x0000000103379d79 _ZN2CA5Layer16layout_if_neededEPNS_11TransactionE + 401 18 Quartz 0x0000000103302851 _ZN2CA7Context18commit_transactionEPNS_11TransactionE + 385 19 Quartz 0x000000010332e1c2 _ZN2CA11Transaction6commitEv + 500 20 UIKit 0x00000001052b11de __34- [UIApplication _firstCommitBlock] _block_invoke_2 + 141 21 Corefoundation 0x00000001026b82ac __CFRUNLOOP_IS_CALLING_OUT_TO_A_BLOCK + 12 22 Corefoundation 0x000000010269cadb __CFRunLoopDoBlocks + 203 23 Corefoundation 0x000000010269c2b4 __CFRunLoopRun + 1300 24 CoreFoundation 0x000000010269bb29 CFRunLoopRunSpecific + 409 25 Grafikservices 0x000000010aa059c6 GSEventRunModal + 62 2 6 UIKit 0x00000001052959a4 UIApplicationMain + 159 27 JahanCo Katalog 0x0000000100754ed7 main + 55 28 libdyld.dylib 0x000000010750f621 start + 1 29 ??? 0x0000000000000001 0x0 + 1 ) libC++ abi.dylib: endet mit abgefangene Ausnahme vom Typ NSException (LLDB)
, wo Sie TopProducts deklariert? –
UICollectionView benötigt ein flowLayout – junaidsidhu
Sie möchten die Einschränkungen von collectionView, die mit storyBoard über Code hinzugefügt wurden, ändern? –