开发者

pushViewController to open a view in landscape

开发者 https://www.devze.com 2023-01-20 05:00 出处:网络
I am trying to open a view in landscape by pushing on navigation controller but it always open in portrait.

I am trying to open a view in landscape by pushing on navigation controller but it always open in portrait.

First view is in portrait and when I click on a button then next view should be in landscape.

I am trying following code

Calling View:

ResultViewController *resultView = [[ResultViewController alloc] init];
    [[self navigationController] pushViewController:resultView animated:YES];

View that should open in landscape:

- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation {
        return (interfaceOrientat开发者_如何转开发ion == UIInterfaceOrientationLandscapeLeft);
}

Is there something else to try here?

Thanks


Try..

- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation {
    //return UIInterfaceOrientationIsLandscape(interfaceOrientation);
    return ((interfaceOrientation == UIInterfaceOrientationLandscapeRight) || (interfaceOrientation == UIInterfaceOrientationLandscapeLeft));
}

and then...

- (void)viewDidLoad {
    [[UIApplication sharedApplication] setStatusBarOrientation:UIDeviceOrientationLandscapeLeft animated:YES];

}

in resultView

0

精彩评论

暂无评论...
验证码 换一张
取 消