3
私は次のことを試していますが、新しいviewcontrollersビューを追加できませんでした。それはビューコントローラを提示するための唯一の方法ですか?他のストーリーボードviewcontrollersビューからビューを追加しますか?サブビューとして新しいViewControllerのビューを追加する
//Working
let vc = UIStoryboard(name: "Main", bundle: nil).instantiateViewController(withIdentifier: "customView") as! CustomViewController
self.present(viewcontroller , animated: true, completion: nil)
//Not working
let vc = UIStoryboard(name: "Main", bundle: nil).instantiateViewController(withIdentifier: "customView") as! CustomViewController
vc.view.frame = self.view.frame
self.view.addSubview(vc.view)
あなたは別の1行 –
を逃したかvc.willMove(toParentViewController:自己)を使用すること –
を。 –