重定向到导航堆栈中的新视图控制器
我对iOS中的导航视图控制器和堆栈相当陌生。请帮助我,尝试搜索很长一段时间找不到任何相关的东西。重定向到导航堆栈中的新视图控制器
我有一个LoginViewController,一个用于侧菜单操作的SWRevealViewController,一个FirstViewController(导航堆栈中的第一个)和一个SecondViewController(导航堆栈中的第二个)。
我必须做在LoginViewController以下,假设登录,发现有两个布尔变量:
if (login && !found) {
//redirect to FirstViewController : the following works
[self presentViewController:swReveal animated:NO completion:nil];
}
else if (login && found) {
//redirect to SecondViewController
}
请帮我填写否则如果。真的很感谢你的时间!
因此,基于我从您的意见中了解的内容,FirstViewController是TableViewController的子类,SecondViewController是DetailView。
所以此基础上,对“重定向”到的DetailView(SecondViewController),将创建的故事情节进行SEGUE,然后调用编程一旦FirstViewController被加载(在其viewDidLoad中),其赛格瑞
最好的方法在这两种情况下,您将首先显示FirstViewController,然后根据if语句,您将停留或转到SecondViewController。
所以第一步:从Storyboard创建一个segue,并给它一个标识符。
二:当FirstViewController被加载(当然,如果该语句是有效的)通过编程执行该赛格瑞:
[self performSegueWithIdentifier: @"MySegue" sender: self];
更多关于这个问题的:
Alternative ways to push view controllers with storyboard programmatically
非常感谢您的回答.. 这意味着我必须通过FirstViewController吗?我不能直接去SecondViewController ..?理想情况下,我想这样做。 根据这个在LoginViewController中,如果找到beacon,我将一些FirstViewController的变量设置为true,并且在FirstViewController的viewDidLoad中,如果变量为true,则执行Segue。 – 2014-11-03 10:31:11
是的,我认为这是如果你想回到FirstViewController的方式,因为它是第一个堆栈。 – RJiryes 2014-11-03 10:34:28
那么你在哪里实际使用FirstViewController?为什么你需要它,如果你不提交它?也许包括你的故事板的截图,使你要求更清晰。 – RJiryes 2014-11-03 08:47:51
如果找到的变量为假,我需要FirstViewController。 具体应用是,如果手机在附近发现一个信标,则发现= YES,然后重定向到SecondViewController。 SecondViewController是FirstViewController的DetailView单元格,它是一个tableView。 – 2014-11-03 09:02:59