我有一个 Storyboard,它有 2 个 View Controller ,包括 UINavigationController 本身。我对应用程序进行了一些更改,但奇怪地出现了该错误。
*** Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'Could not load NIB in bundle: 'NSBundle </Users/***/Library/Developer/CoreSimulator/Devices/96021E81-BD05-4193-86ED-7F386739B99E/data/Containers/Bundle/Application/E684814B-7F84-41CE-B762-64C66A4AE4F8/***.app> (loaded)' with name '5JK-D5-ZKP-view-1nz-4p-isc''
我尝试禁用Size Classes,但没有用。我还深入研究了 Storyboard XML,发现 5JK-D5-ZKP
是导航 Controller 中的 root view controller
和 1nz-4p -isc
是 UITableViewController
中的 TableView ,它是 Root View Controller 。
最佳答案
问题的原因是 UITableViewController
子类中的自定义初始化及其方法 init(coder aDecoder: NSCoder)
。由于没有其他初始化方法在那里被覆盖,该覆盖大致类似于:
required init?(coder aDecoder: NSCoder) {
// Initialize fetcher
fetcher = QuestionFetcher(delegate: self)
// Call the super.init method
super.init(coder: aDecoder)
// Initialize the activity indicator for fetching questions
activityIndicator = UIActivityIndicatorView(frame: CGRect(x: tableView.frame.size.width / 2.00, y: tableView.frame.size.height / 2.00, width: 20, height: 20))
activityIndicator.hidesWhenStopped = true
activityIndicator.hidden = true
}
有什么棘手的地方, Storyboard中签名的读者试图调用覆盖中的 init?(coder: NSCoder)
,但是如您所见,它是一个 failable initializer .但是那个 View Controller 不是从编码器加载的,所以它失败了。
关于ios - 无法在名称为 : '5JK-D5-ZKP-view-1nz-4p-isc' 的包中加载 NIB,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35675423/