How to set one of the screens in landscape mode in iphone?

≯℡__Kan透↙ 提交于 2019-12-28 06:55:10

问题


I am developing iphone application in iOS7, i am facing problem in autorotate single screen in landscape mode programatically, while other screens remains in portrait mode. I am using Story board.


回答1:


I used following and its working for me in both iOS6 and iOS7 also,try following way :

// Added method for Autorotation in you app delegate
- (NSUInteger)application:(UIApplication *)application supportedInterfaceOrientationsForWindow:(UIWindow *)window{
    //NSLog(@"AppDelegate -- supportedInterfaceOrientationsForWindow");
    if([UICommonUtils isiPhone]){
        return UIInterfaceOrientationMaskPortrait;
    }else if(flagOrientationAll == YES){
        return UIInterfaceOrientationMaskLandscape;
    } 
}

Add following in your view controller

// set flag "flagOrientationAll" to rotate only one view in your perticular view 
-(void)viewWillAppear:(BOOL)animated
{
    NSLog (@"webViewController -- viewWillAppear");
    [super viewWillAppear:animated];
 PlayWithWSWithLibAppDelegate *delegate = (PlayWithWSWithLibAppDelegate *) [[UIApplication sharedApplication] delegate];
    delegate.flagOrientationAll = YES;
}

-(void)viewWillDisappear:(BOOL)animated
{
    NSLog (@"webViewController -- viewWillDisappear");
    PlayWithWSWithLibAppDelegate *delegate = (PlayWithWSWithLibAppDelegate *)[[UIApplication sharedApplication] delegate];
    delegate.flagOrientationAll = NO;

}


来源:https://stackoverflow.com/questions/19422373/how-to-set-one-of-the-screens-in-landscape-mode-in-iphone

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!