1
我正在构建一个应用程序来呈现UIViewController
并同时关闭当前的UIViewController
。Present and dismiss last UIViewController
目前我在viewcontroller1
,我想提出viewcontroller2
作为主控制器和罢免viewcontroller1
从内存中删除,所以viewcontroller2
将呈现后的主控制器并且在堆栈中没有viewcontroller1
。
我已经试过:
let controller = storyboard?.instantiateViewControllerWithIdentifier("controller2") as! viewcontroller2
controller.modalTransitionStyle = UIModalTransitionStyle.CrossDissolve
self.dismissViewControllerAnimated(false) {() -> Void in
self.presentViewController(controller, animated: false, completion: nil)
}
但它给了我:0x7fee28711900> whose view is not in the window hierarchy!
有没有一种方法可以做到这一点?
我在哪里做?第二个呈现的控制器的viewDidLoad?所以通过应用你的代码它会从内存中关闭旧的视图控制器? –
我建议你集中你的逻辑来呈现视图控制器 - 也许在你的应用程序委托中,或者更好的是,在专用的控制器类中,并将上面的代码放在那里。 –
通过指向帖子的链接更新了答案,向您展示了如何进行动画制作。 –