推出一个自定义的alertVC
我们需要将设置
alertVC.modalPresentationStyle = UIModalPresentationOverCurrentContext;
LandscapeViewController
- (BOOL)shouldAutorotate{
return NO;
}
- (UIInterfaceOrientation)preferredInterfaceOrientationForPresentation{
return UIInterfaceOrientationLandscapeRight;
}
-(UIInterfaceOrientationMask)supportedInterfaceOrientations{
return UIInterfaceOrientationMaskLandscapeRight;
}
LandscapeViewController* alertVC = [LandscapeViewController new];
alertVC.modalPresentationStyle = UIModalPresentationOverCurrentContext;
UIWindow* alertWindow = [[UIWindow alloc] initWithFrame:[UIScreen mainScreen].bounds];
alertWindow.rootViewController = [LandscapeViewController new];
alertWindow.windowLevel = UIWindowLevelAlert + 1;
[alertWindow makeKeyAndVisible];
CGAffineTransform rotation = CGAffineTransformMakeRotation(M_PI_2);
[alertWindow setTransform:rotation];
alertWindow.frame = CGRectMake(0, 0, alertWindow.frame.size.width, alertWindow.frame.size.height);
self.alertWindow = alertWindow;
[alertWindow.rootViewController presentViewController:alertVC animated:NO completion:nil];
网友评论