强制横屏(此方法为旋转视图)
- (void)loadView{
self.view = [[UIView alloc]init];
CGRect frame = [UIScreen mainScreen].bounds;
AppDelegate *app = (AppDelegate *)[UIApplication sharedApplication].delegate;
UIDeviceOrientation duration = [[UIDevice currentDevice]orientation];
if (duration == UIDeviceOrientationLandscapeLeft) {
app.window.transform = CGAffineTransformMakeRotation(M_PI*0.5);
[[UIApplication sharedApplication] setStatusBarOrientation:UIDeviceOrientationLandscapeLeft animated:YES];
}else{
app.window.transform = CGAffineTransformMakeRotation(M_PI*1.5);
[[UIApplication sharedApplication] setStatusBarOrientation:UIDeviceOrientationLandscapeRight animated:YES];
}
app.window.bounds = CGRectMake(0, 0, frame.size.height, frame.size.width);
}
恢复竖屏
app.window.transform = CGAffineTransformIdentity;
网友评论