0

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

4

1 回答 1

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;

}
于 2013-10-17T09:39:15.593 回答