Error when moving view Controller

2019-09-05 22:02发布

I get an error saying

*** Assertion failure in -[HatsViewController loadView], /SourceCache/UIKit/UIKit-2380.17/UICollectionViewController.m:104    

*** Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: '-[UICollectionViewController loadView] loaded the "FCD-ki-UFO-view-1vb-8P-s3C" nib but didn't get a UICollectionView.'
    *** First throw call stack:
    (0x3467c2a3 0x3c36097f 0x3467c15d 0x34f51ab7 0x368aaa95 0x364a346d 0x3652f353 0x36570d11 0x3656ffe7 0x366923ef 0x3656f0c5 0x3656f077 0x3656f055 0x3656e90b 0x3656ee01 0x364975f1 0x36484801 0x3648411b 0x3818b5a3 0x3818b1d3 0x34651173 0x34651117 0x3464ff99 0x345c2ebd 0x345c2d49 0x3818a2eb 0x364d8301 0xc0dfd 0x3c797b20)
    libc++abi.dylib: terminate called throwing an exception
    (lldb) 

Why does this happen and how can I fix it?

2条回答
成全新的幸福
2楼-- · 2019-09-05 22:42

check HatsViewController.h is inherited from UICollectionViewController but you have connected it view in your storyboard. Either it must be subclass of UIViewController or it is connected to UICollectionView in your storyboard.

查看更多
The star\"
3楼-- · 2019-09-05 22:50

When you’re using a UICollectionViewController, the view outlet needs to be connected to a UICollectionView in your storyboard; if it’s a UIView of another class, it’ll crash.

查看更多
登录 后发表回答