如何只为我的两个视图控制器提供方向支持?
我如何为应用程序中的两个视图控制器提供方向支持?感染我有一个基于选项卡栏的应用程序,并且我在选项卡栏中添加了导航项目。我有一个自定义 TabBarViewController ,在该视图控制器中我允许方向,
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation {
return YES;
}
现在我不希望每个视图控制器都支持方向。我只需要在两个或三个视图控制器中使用它。当我在任何视图控制器中编写 return (interfaceOrientation = UIInterfaceOrientationPortrait); 时,它不起作用,并且应用程序仍然在改变其方向。如果我停止 CustomTabBarViewController 的方向,那么它会停止整个应用程序的方向。
有人可以帮助我吗? 我刚刚被困在这里
提前致谢
Ho wcan i give orientation support to two of my viewcontrollers in my app? Infect i have a tabbar based application and ii have added navigation items in tabbar. i have a custom TabBarViewController and in that view controller i allow orientation
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation {
return YES;
}
now i don't want orientation support in every view controller. I need it only in two or three viewcontrollers. when i write return (interfaceOrientation = UIInterfaceOrientationPortrait);
in any view controller, it do not work, and application remain changing its orientation. and if i stop orientation from my CustomTabBarViewController then it stops the orientation of whole application.
can any one help me?
I just got stuck here
Thanks in advance
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
我认为如果使用 tabBars 就无法做到这一点。当使用 tabbarcontroller 并且请求更改方向时,它将调用挂在 tabbarcontroller 中的每个视图控制器,无论它是否可见。
因此,如果他们中的任何一个人回答“否”,那么没有人会改变。
这有点像“所有人或无人”。
I think that you can't do that if using tabBars. When using a tabbarcontroller and a change of orientation is request, it will called every viewcontroller that hangs in the tabbarcontroller, doesn't matter if it is visible.
So if any of them answers NO, no one will change.
It's something like "of everyone or no one".
标签栏不会旋转,除非它的所有视图控制器都会旋转。
http://www.cimgf。 com/2008/11/13/landscape-tab-bar-application-for-the-iphone/
A tabbar won't rotate unless all it's viewcontrollers will.
http://www.cimgf.com/2008/11/13/landscape-tab-bar-application-for-the-iphone/