在UITabBar应用程序中旋转一个UIViewController

我有uitabbar应用程序,我想旋转一个ViewController与横向模式的图表。 有可能做到这一点?

在横向模式下只有一个视图,而其他视图处于横向模式,没有一种简单的方法,也不是以编程方式切换到横向模式的简单方法。

一种可能的方法是使用CGAffineTransformviewWillAppear转换视图(即,在显示视图之前):

 - (void)viewWillAppear:(BOOL)animated; { //-- Adjust the status bar [UIApplication sharedApplication].statusBarOrientation = UIInterfaceOrientationLandscapeRight; //-- Rotate the view CGAffineTransform toLandscape = CGAffineTransformMakeRotation(degreesToRadian(90)); toLandscape = CGAffineTransformTranslate(toLandscape, +90.0, +90.0 ); [self.view setTransform:toLandscape]; } 

希望这对你有用。

只有它是模态的,如果它是tabBarController的一部分,则需要支持所有控制器的方向更改