在我正在使用的应用程序中,我有一个配置文件选项卡,用户可以在其中查看与其帐户相关的所有信息,其中一个字段是他们参加的大学,而该字段旁边的是一个按钮,可以从表格中进行选择他们去的大学的价值观的看法。这是个人资料视图的屏幕截图:
当我点击选择按钮时,它将带我到具有大学列表的表格的另一个视图,一旦我选择了一个,它将带我回到配置文件视图,除非当我回到配置文件视图时,导航栏和buttom菜单丢失:
这是我在视图控制器之间使用的代码:
ProfileView * vc = [[ProfileView alloc] init];
[self presentViewController:vc animated:YES completion:^{
}];
有谁知道为什么会这样?
Is ProfileView
a subclass of UIView
or UIViewController
? In the latter case it should be renamed to ProfileViewController
as the current name suggests that its a custom view. Otherwise, as comments suggest, you need to create a UIViewController for that view, if you going to use the following methods:
Presenting the detail view controller:
You're using [self presentViewController]
which will simply present a view controller by sliding it from the bottom of the screen. On completion it can be dismissed with [vc dismissViewControllerAnimated:completion]
. If you want a navigation bar to be included you can either:
For the latter case:
[self presentViewController:[[UINavigationController alloc]
initWithRootViewController:vc]];
Alternatively, you can push the next view controller onto the current navigation controller's stack using:
[self.navigationController pushViewController:vc animated:YES];
。。。这将使视图控制器从右侧滑过。
最后,对于某些替代方法,如果希望的话,可以使用以下方法显示ViewController和/或视图:
[UIView transitionWithView . . . ]
。。但是,根据您在问题中描述的要求,不需要这些。
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句