添加下面代码到 控制器中
@property(nonatomic,assign)BOOL isPortraitMode;
@synthesize isPortraitMode=_isPortraitMode;
- (UIInterfaceOrientation)preferredInterfaceOrientationForPresentation{
if (_isPortraitMode) {
return UIInterfaceOrientationPortrait;
}else{
return UIInterfaceOrientationLandscapeRight;
}
}
-(NSUInteger)supportedInterfaceOrientations
{
if (_isPortraitMode) {
return UIInterfaceOrientationMaskPortrait;
}else{
return UIInterfaceOrientationMaskLandscape;
}
}
-(BOOL)shouldAutorotate
{
if (_isPortraitMode) {
return NO;
}else{
return YES;
}
}
-(void)setIsPortraitMode:(BOOL)isPortraitMode{
DLog();
_isPortraitMode=isPortraitMode;
__strongUIViewController * strSelf = self;
__strongUIViewController * strFatherViewController =self.presentingViewController;
[strFatherViewController dismissViewControllerAnimated:NOcompletion:nil];
[strFatherViewController presentViewController:strSelfanimated:NOcompletion:nil];
if (isPortraitMode==YES) {
self.view.bounds=CGRectMake(0,0, Dev_ScreenWidth,Dev_ScreenHeight);
}else{
//
self.view.bounds=CGRectMake(0,0, Dev_ScreenHeight,Dev_ScreenWidth);
}
}