IOS 7 +用于力控制器朝向纵向

时间:2013-09-26 17:21:22

标签: iphone orientation ios7

我在IO6及以下版本中使用了以下代码来强制旋转:

-(void) viewWillAppear:(BOOL)animated
{
    [super viewWillAppear:animated];
    UIApplication* application = [UIApplication sharedApplication];
    if (application.statusBarOrientation != UIInterfaceOrientationPortrait)
    {
        UIViewController *c = [[UIViewController alloc]init];
        [c.view setBackgroundColor:[UIColor redColor]];
        [self.navigationController presentViewController:c animated:NO completion:^{
            [self.navigationController dismissViewControllerAnimated:NO completion:^{
            }];
        }];
    }
}

但它在IOS7上无法正常工作,它会旋转视图控制器但又在屏幕上设置空白视图......

你能帮助我在IOS 7中解决这个问题......

1 个答案:

答案 0 :(得分:3)

更改此行:

[self.navigationController dismissViewControllerAnimated:NO completion:^{
    }];

对此:

[self.navigationController dismissViewControllerAnimated:YES completion:^{
    }];