我有一个iPhone应用程序,该应用程序始终可以纵向运行。

此应用程序具有导航视图控制器和rootViewcontroller(也以纵向显示)。我想在iPhone变为横向时显示viewController,并在应用回到纵向时关闭此视图控制器。

目前,我已经实现了这一目标,但是我的观点完全被感动:

第1步:

第2步:

第三步:

我尝试了几种方法,但不知道是否选择了正确的方法:

-(BOOL)shouldAutorotate
{
     return YES;
}

-(void)willRotateToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation     duration:(NSTimeInterval)duration
{


 }

-(void)didRotateFromInterfaceOrientation:(UIInterfaceOrientation)fromInterfaceOrientation
{
    if ([[UIApplication sharedApplication] statusBarOrientation] ==    UIInterfaceOrientationLandscapeLeft || [[UIApplication sharedApplication]  statusBarOrientation] == UIInterfaceOrientationLandscapeRight) {
        UIStoryboard *currentStoryboar = [self storyboard];
        ASTBigProgressViewController *bigProgress = [currentStoryboar instantiateViewControllerWithIdentifier:@"ASTBigProgressViewController"];
        [self presentViewController:bigProgress animated:YES completion:^{

        }];
    }
}
-(NSUInteger)supportedInterfaceOrientations
{
    return (UIInterfaceOrientationMaskPortrait | UIInterfaceOrientationMaskLandscapeLeft |
            UIInterfaceOrientationMaskLandscapeRight |     UIInterfaceOrientationMaskPortraitUpsideDown);
}

我希望当视图控制器被旋转时,它不会旋转视图以将其保持在同一位置。我试过了:
-(BOOL)shouldAutorotate
{
     return NO;
}

但是很明显,没有调用didRotateFromInterfaceOrientation方法。

任何想法?

最佳答案

您在寻找Creating an Alternate Landscape Interface上的Apple文档。

10-07 19:56
查看更多