我有uitabbar应用程序,我只想在横向模式下旋转一个带有图表的ViewController。可以做到吗?
没有
简单的方法可以只有一个视图处于横向模式,而其他视图处于横向模式,也没有简单的方法可以编程方式切换到横向模式。
一种可能的方法是使用CGAffineTransform
在viewWillAppear
中转换视图(即,就在显示视图之前):
- (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 的一部分,您才需要支持所有控制器的方向更改