【发布时间】:2014-07-29 22:56:11
【问题描述】:
我是 Swift 编程新手,我有一个带有目标功能的按钮:
func buttonAction(sender:UIButton!)
{
self.window.rootViewController.presentViewController(FirstViewController(), animated: true, completion: nil);
}
然而,我在 FirstView(FirstViewController)上有一个按钮,但我想回到 MainView(MainViewController),我得到错误代码:
2014-07-30 00:53:44.545 FifthTry[30275:833440] Warning: Attempt to present
<_TtC8FifthTry19FirstViewController: 0x787b5470> on <_TtC8FifthTry18MainViewController:
0x799802d0> whose view is not in the window hierarchy!
怎么了?
【问题讨论】:
-
这个
buttonAction方法是在 UIViewController 子类上实现的吗? -
嗨,我将“视图”从控制器中分离出来,所以我有一个单独的文件用于视图和控制器,在这种情况下,我在视图 Swift-File 中实现了方法
标签: button controller navigation swift back