iPhone Landscape FAQ and Solutions

后端 未结 6 1706
难免孤独
难免孤独 2020-11-27 11:19

There has been a lot of confusion and a set of corresponding set of questions here on SO how iPhone applications with proper handling for Landscape/Portrait mode autorotatio

6条回答
  •  时光说笑
    2020-11-27 11:41

    I had an interesting requirement for ios application:

    main viewController should be only landscape, but all others (which can be pushed from main) can be landscape and portrait.

    Problem occours - when I push to a new viewController, which then is rotated to portraited - and the pop back - main view is no longer landscape. Also - opening application, it is not in landscape.

    In order to keep main viewcontroller landscape, no matter from what orientation it was popped/pushed, I did the following thing: (in viewWillAppear:)

    //set statusbar to the desired rotation position
    [[UIApplication sharedApplication] setStatusBarOrientation:UIDeviceOrientationLandscapeLeft animated:NO];
    
    //present/dismiss viewcontroller in order to activate rotating.
    UIViewController *mVC = [[[UIViewController alloc] init] autorelease];
    [self presentModalViewController:mVC animated:NO];
    [self dismissModalViewControllerAnimated:NO];
    

    Hopefully it will help someone!

    P.S.Tested on sdk 3.2.5 ios 5.0.1.

    P.S. Thanks for all the info in this FAQ!

提交回复
热议问题