UITabBarController +自动旋转 [英] UITabBarController + autorotation

查看:67
本文介绍了UITabBarController +自动旋转的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用IB创建了一个具有TabBarController的应用程序,该应用程序具有4个TabBarItems,因此显示4个不同的ViewControllers. 为了允许横向放置,我必须在所有ViewController中添加以下代码:

I created an application with a TabBarController using IB who have 4 TabBarItems and so display 4 differents ViewControllers. To allow a landscape orientation I must add this code in all of my ViewController:


- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation {
     return (interfaceOrientation == UIInterfaceOrientationPortraitUpsideDown ? NO : YES);
}

问题是我不希望例如secondViewController自动旋转,我该怎么做? 因为每次我在其中一个ViewController中删除上面的代码时,每个ViewController都不再旋转.

The problem is I don't want for example the secondViewController to autorotate, How can I do that? Because everytime I delete the code above in one of my ViewController, every ViewControllers not rotate anymore.

谢谢

推荐答案

将代码保留在其中,但是您需要执行以下两项操作之一:

Leave the code in there, but you'll want to do one of two things:

  1. 显示横向视图时禁用不可旋转的标签,或者
  2. 在该标签的viewWillAppear或viewDidAppear中,强制旋转为纵向.

例如:

[[UIApplication sharedApplication] setStatusBarOrientation:UIInterfaceOrientationPortrait animated:YES]

这篇关于UITabBarController +自动旋转的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆