如何在iphone中以横向模式设置其中一个屏幕? [英] How to set one of the screens in landscape mode in iphone?

查看:143
本文介绍了如何在iphone中以横向模式设置其中一个屏幕?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在iOS7中开发iphone应用程序,我在编程方式中以横向模式在自动旋转单屏幕中遇到问题,而其他屏幕仍处于纵向模式。
我正在使用故事板。

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.

推荐答案

我在iOS6和iOS7中使用了以下和它的工作原理,尝试以下方式:

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;

}

这篇关于如何在iphone中以横向模式设置其中一个屏幕?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆