iphone: Forcefully change orientation from portrait to landscape on navigation

前端 未结 3 1248
名媛妹妹
名媛妹妹 2021-01-06 16:07

Is there any way that we can Forcefully change app orientation from portrait to landscape while navigating ?

I have a requirement that while pushing controller from

3条回答
  •  没有蜡笔的小新
    2021-01-06 16:56

    In - (void)viewWillAppear:(BOOL)animated say:

        //this is to force the application to re-evaluate device orientation
        //comment the last lines and see
        //cannot use [[UIDevice currentDevice] setOrientation:UIInterfaceOrientationLandscapeLeft];
        //as "setOrientation" is a private method, and we risk to be kicked out by Apple
        UIViewController *c = [[[UIViewController alloc]init] autorelease];
        [self presentModalViewController:c animated:NO];
        [self dismissModalViewControllerAnimated:NO];
    

    ... but first, in your xib, set your view's orientation to the desired one

提交回复
热议问题