Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/ios/121.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/git/20.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Ios 重定向到导航堆栈中间的新视图控制器_Ios_Xcode_Uiviewcontroller_Uinavigationcontroller_Uinavigationitem - Fatal编程技术网

Ios 重定向到导航堆栈中间的新视图控制器

Ios 重定向到导航堆栈中间的新视图控制器,ios,xcode,uiviewcontroller,uinavigationcontroller,uinavigationitem,Ios,Xcode,Uiviewcontroller,Uinavigationcontroller,Uinavigationitem,我对iOS中的导航视图控制器和堆栈相当陌生。请帮我做这个,搜索了很长时间都找不到任何相关的东西 我有一个LoginViewController、一个用于侧菜单操作的SWRevealViewController、一个FirstViewController(导航堆栈中的第一个)和一个SecondViewController(导航堆栈中的第二个) 我必须在LoginViewController中执行以下操作,假设login和found是两个布尔变量: if (login && !fou

我对iOS中的导航视图控制器和堆栈相当陌生。请帮我做这个,搜索了很长时间都找不到任何相关的东西

我有一个LoginViewController、一个用于侧菜单操作的SWRevealViewController、一个FirstViewController(导航堆栈中的第一个)和一个SecondViewController(导航堆栈中的第二个)

我必须在LoginViewController中执行以下操作,假设login和found是两个布尔变量:

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中)后以编程方式调用该segue

在这两种情况下,您将首先显示FirstViewController,然后根据if语句,您将停留或转到SecondViewController

因此,第一步:从故事板创建序列,并给它一个标识符

第二:在加载FirstViewController(当然,if语句是有效的)时,使用以下命令以编程方式执行该序列:

[self performSegueWithIdentifier: @"MySegue" sender: self];
关于这一主题的更多信息:


那么,您实际在哪里使用FirstViewController?如果不演示,为什么需要它?可能包括故事板的屏幕截图,以便更清楚地了解您的要求。如果找到的变量为false,我需要FirstViewController。具体的应用是,如果手机在附近发现一个信标,则find=YES,然后重定向到SecondViewController。SecondViewController是FirstViewController的DetailView单元格,它是一个tableView。非常感谢您的回答。。这意味着我必须通过FirstViewController,对吗?我不能直接转到SecondViewController?理想情况下,我想这样做。根据LoginViewController中的这一点,如果找到beacon,我会将FirstViewController的变量设置为true,而在FirstViewController的viewDidLoad中,我会检查变量是否为true。是的,如果您想返回FirstViewController,我想这是一种方法,因为它是堆栈上的第一个变量。