我尝试在一个FUNC开第二视图控制器但出现这种错误:需要试图提出<UINavigationController的>上firstController其视图不在窗口层级
Attempt to present
<UINavigationController>
on firstController whose view is not in the window hierarchy!
所有溶液:
要么把代码内viewWillAppear()
或内部IBAction
FUNC
我的程序需要从正常FUNC
打开第二视图控制器0我尝试了所有这代码:
代码1:
self.performSegueWithIdentifier("page2", sender:self)
结果:
error: has no segue with identifier 'page2''
代码2:
let secondViewController:page2 = page2()
self.presentViewController(secondViewController, animated: true,completion: nil)
RES ULT:
error: whose view is not in the window hierarchy!
代码3:
let nextViewController = storyboard!.instantiateViewControllerWithIdentifier("next2") as! UIViewController
self.presentViewController(nextViewController, animated:true, completion:nil)
结果:
fatal error: unexpectedly found nil fwom win func
代码4:
let storyBoard : UIStoryboard = UIStoryboard(name: "Main", bundle:nil)
let nextViewController = storyBoard.instantiateViewControllerWithIdentifier("next2") as! page2
self.presentViewController(nextViewController, animated:true, completion:nil)
dismissViewControllerAnimated(true, completion:nil)
结果:
error whose view is not in the window hierarchy!
我需要一个解决方案,请。
塞格可能是你的第一个考虑因素,但塞格标识符并不是视图的名称。您需要将第一个视图连接到故事板中的导航视图,并给出一个标识符以便能够使用此功能。 – zcui93
是的,我让segue的名字是第2页的代码和故事板中,我也改变了segue的名字到另一个名字,但它不工作 – ematalb
在故事板中有你的segue的截图应该有所帮助。 – zcui93