[英]Create ViewController using nib in ViewDidLoad return nil
我有一個容器ViewController A和一個子ViewController B在ViewController A的viewDidLoad中,我從筆尖初始化ViewControler B並將其添加為Viewcontroller A的子代,但ViewControler B始終為零。
這是我的代碼。
override func viewDidLoad() {
self.currentViewController =
ViewControlerB(nibName: "ViewControllerB", bundle: nil)
self.currentViewController!.view
.translatesAutoresizingMaskIntoConstraints = false
self.addChildViewController(self.currentViewController!)
self.addSubView(self.currentViewController!.view,
toParentView: viewContainer)
super.viewDidLoad()
}
我的self.currentViewController始終為零,並導致崩潰。 誰能向我解釋為什么?
等離子幫助^^'
希望您檢查以下兩個答案:
1-檢查筆尖名稱。
2-將束從零更改為(NSBundle.mainBundle())。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.