我有一个ViewController和单独的nib文件。我最初的root viewcontroller设置在storyBoard中。现在的问题是,当我推送到该 Controller 时,没有调用Viewhirachy方法(ViewDidLoad,ViewWillApper等)。
代码(已加载 View ,但未调用方法)
var viewController = UIViewController(nibName: "OfferDetailViewController", bundle: nil) as OfferDetailViewController
self.navigationController?.pushViewController(viewController, animated: true);
如果我对 Storyboard 进行同样的操作,则效果相同。
let mainStoryboard: UIStoryboard = UIStoryboard(name: "Main", bundle: nil)
var viewController = mainStoryboard.instantiateViewControllerWithIdentifier("offer") as OfferDetailViewController
self.navigationController?.pushViewController(viewController, animated: true);
问题:使用 Storyboard 的 View 层次结构方法正在调用,但不是使用单独的nib文件?
最佳答案
var viewController = OfferDetailViewController(nibName: "OfferDetailViewController", bundle: nil)