ios - 无法在名称为 : '5JK-D5-ZKP-view-1nz-4p-isc' 的包中加载 NIB

标签 ios swift uistoryboard nsbundle

我有一个 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 controller1nz-4p -iscUITableViewController 中的 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/

相关文章:

xcode - Swift:使用未解析的标识符 'addChild'

objective-c - 原型(prototype) UITableViewCell 不在 Storyboard 中的 UITableView 顶部

ios - 如何以编程方式覆盖 Storyboard UIView 高度属性

ios - 实例成员不能用于嵌套类型的实例?

ios - 在应用程序中为特定目标编写 if 条件

ios - 观察者被过度释放或粉碎

快速组合 : How can I convert `AnyPublisher<[Foo], *>` to `AnyPublisher<Foo, *>` ?

ios - 在子上下文中保存会自动保存到父上下文

ios - UIViewController 容器不显示 ChildViewController

ios - 如何在 Storyboard 中使用 ViewController 的自定义初始化