當我在從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)
}
我有這個在我的iOS項目的一個工作更新到Xcode 8
和Swift 3
語言,但現在當我運行應用程序時,遇到vc.present(customDialog, animated: true, completion: nil)
行時出現崩潰。我在日誌控制檯得到這個消息:
終止應用程序由於未捕獲的異常「NSInternalInconsistencyException」,理由是:「無法加載NIB捆綁:‘一個NSBundle /MyApp.app>(裝載)’名爲‘CustomDialogViewController’ 「
我不明白它正在發生,因爲let customDialog = CustomDialogViewController(nibName: "CustomDialogViewController", bundle: bundle)
線不會崩潰,似乎我收到了CustomDialogViewController
對象。
有人可以幫我解決這個問題嗎?謝謝
您確定__customDialog__被實例化嗎? – Adeel
您已經在標籤中指明瞭「Xcode 8&swift 3」,無需在標題中添加它。 –