-1

I have this function in a class that inherits from NSObject:

open func showCustomDialogInView(vc: UIViewController) {
    let bundle = Bundle(for: CustomDialogViewController.self)
    let customDialog = CustomDialogViewController(nibName: "CustomDialogViewController", bundle: bundle)
    customDialog.delegate = vc
    customDialog.modalPresentationStyle = UIModalPresentationStyle.overCurrentContext
    vc.present(customDialog, animated: true, completion: nil)
}

I had this working in one of my iOS projects before updating to Xcode 8 and Swift 3 language, but now when I run the app I get a crash when vc.present(customDialog, animated: true, completion: nil) line is reached. I get this message in log console:

Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'Could not load NIB in bundle: 'NSBundle /MyApp.app> (loaded)' with name 'CustomDialogViewController''

I don't understand what it is happening, since let customDialog = CustomDialogViewController(nibName: "CustomDialogViewController", bundle: bundle) line doesn't crash and it seems that I get a CustomDialogViewController object.

Does somebody could help me with this issue? Thanks

4

2 回答 2

0

当您在 XCode 之外重命名文件时,可能会发生此错误。要解决它,您只需从项目中删除文件(右键单击 - 删除和“删除引用”)。

然后在您可以重新导入项目中的文件之后,一切都会好起来的。

于 2016-10-22T20:30:40.007 回答
0

在这种情况下,此错误似乎是因为由于某种原因xib文件缺少适当的目标成员资格。

感谢您的回答

于 2016-10-23T14:11:04.150 回答