Hindu
Hindu

Reputation: 2914

IOS 7 + For force controller Orientation to Portrait

I have used below code for IO6 and below to force rotate:

-(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:^{
            }];
        }];
    }
}

But it is not working correctly on IOS7, it rotate view controller but again set blank view on screen...

Can you help me to solve this issue in IOS 7...

Upvotes: 2

Views: 2779

Answers (1)

Austin
Austin

Reputation: 449

Change this line:

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

To this:

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

Upvotes: 3

Related Questions