本文介绍了在UITabBar应用程序中旋转一个UIViewController的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有uitabbar应用程序,我想旋转只有一个ViewController与横向模式的图表。

I have uitabbar application and I Want to rotate just one ViewController with chart in landscape mode. It's possible to do that?

推荐答案

没有简单的方法只有一个视图在横向模式,而其他的

There is no easy way to have only one view in landscape mode, while the others are in landscape, nor an easy way to programmatically switch to landscape mode.

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

One possible approach would be using a CGAffineTransform to transform your view in your viewWillAppear (i.e., right before the view is shown):

- (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];
}

希望这对你有用。

这篇关于在UITabBar应用程序中旋转一个UIViewController的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-14 13:40