如何在iphone中以横向模式设置其中一个屏幕?

时间:2013-10-17 09:05:37

标签: iphone ios7 uistoryboard

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

1 个答案:

答案 0 :(得分:2)

我在iOS6和iOS7中都使用了以下功能,并尝试以下方式:

// 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;
    } 
}

在视图控制器中添加以下内容

// 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;

}