Is there a documented way to set the iPhone orientation?

后端 未结 17 1285
清歌不尽
清歌不尽 2020-11-22 11:09

I have an app where I would like to support device rotation in certain views but other don\'t particularly make sense in Landscape mode, so as I swapping the views out I wou

17条回答
  •  日久生厌
    2020-11-22 11:44

    This is long after the fact, but just in case anybody comes along who isn't using a navigation controller and/or doesn't wish to use undocumented methods:

    UIViewController *c = [[UIViewController alloc]init];
    [self presentModalViewController:c animated:NO];
    [self dismissModalViewControllerAnimated:NO];
    [c release];
    

    It is sufficient to present and dismiss a vanilla view controller.

    Obviously you'll still need to confirm or deny the orientation in your override of shouldAutorotateToInterfaceOrientation. But this will cause shouldAutorotate... to be called again by the system.

提交回复
热议问题