强制让程序改成横屏

来源:互联网 发布:网络喷子喷国家喷党 编辑:程序博客网 时间:2024/06/06 05:37

- (void)viewDidLoad{     [super viewDidLoad];     if ([[UIDevice currentDevice].systemVersion floatValue] < 2.1)    {        UIInterfaceOrientation orientation = [[UIApplication sharedApplication] statusBarOrientation];        if (orientation == UIInterfaceOrientationLandscapeRight)        {             CGAffineTransform transform = self.view.transform;            // use the status bar frame to determine the center point of the window's content area.            CGRect statusBarFrame = [[UIApplication sharedApplication] statusBarFrame];            CGRect bounds = CGRectMake(0, 0, statusBarFrame.size.height, statusBarFrame.origin.x);            CGPoint center = CGPointMake(bounds.size.height / 2.0, bounds.size.width / 2.0);            // set the center point of the view to the center point of the window's content area.            self.view.center = center;            // Rotate the view 90 degrees around its new center point.             transform = CGAffineTransformRotate(transform, (M_PI / 2.0));            self.view.transform = transform;        }    }}


https://developer.apple.com/library/prerelease/ios/#technotes/tn2244/_index.html#//apple_ref/doc/uid/DTS40009012

原创粉丝点击