Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/ios/119.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/5/objective-c/23.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 为什么显示的ViewController不正确?如何显示正确的一个?_Ios_Objective C_Viewcontroller - Fatal编程技术网

Ios 为什么显示的ViewController不正确?如何显示正确的一个?

Ios 为什么显示的ViewController不正确?如何显示正确的一个?,ios,objective-c,viewcontroller,Ios,Objective C,Viewcontroller,如果用户尚未注册用户名等,我将尝试将其发送到注册页面。。我无法加载注册viewController,它只加载MainViewController。 我已经尝试了我能找到的每一种方法,但都不管用。。我的背景是Java/Android,所以这一切都是全新的。如果你能指出正确的方向,我将不胜感激 代码 试试这个 registrationViewController *viewController = (registrationViewController*)[[UIStoryboard storybo

如果用户尚未注册用户名等,我将尝试将其发送到注册页面。。我无法加载注册viewController,它只加载MainViewController。 我已经尝试了我能找到的每一种方法,但都不管用。。我的背景是Java/Android,所以这一切都是全新的。如果你能指出正确的方向,我将不胜感激

代码

试试这个

registrationViewController *viewController = (registrationViewController*)[[UIStoryboard storyboardWithName:@"Main" bundle:NULL] instantiateViewControllerWithIdentifier:@"registrationView"];
而不是

UIViewController *viewController = [[UIStoryboard storyboardWithName:@"Main" bundle:NULL] instantiateViewControllerWithIdentifier:@"registrationView"];
如果以模式显示视图控制器,请使用此打开

[self presentViewController:viewController animated:YES completion:nil];
或者如果您使用
navigationController
,则

[self.navigationController pushViewController:viewController animated:YES];

在当前代码中,您刚刚初始化了viewController。没有显示,推送完成。我已经更新了代码,但它仍然没有执行任何操作,只显示第一个viewcontroller-我收到消息“警告:尝试在不在窗口层次结构中的视图上显示!”您在项目中使用过navigationController吗?是的,它肯定有可能重复
[self.navigationController pushViewController:viewController animated:YES];