iOS 8: Autorotation is not working without storyboard

前端 未结 5 752
清歌不尽
清歌不尽 2021-01-14 06:28

So I am trying to start a project w/o Storyboards and I can\'t seem to figure out why the UIWindow is not passing autorotation commands to the root view controller. With st

相关标签:
5条回答
  • 2021-01-14 06:34

    i just solved the problem in my project. for me, the solution was to remove the animation from the following code:
    [self presentViewController: root animated: animated completion:^{ [AppDelegate singleton].window.rootViewController = root; }]; which is now just [AppDelegate singleton].window.rootViewController = root;

    i don't know if this answers your question, but it solved my instance of what i think is a shared problem.

    0 讨论(0)
  • 2021-01-14 06:37

    Are you using storyboards? If so, you may have old code in your application didFinishLaunchingWithOptions method.

    Try removing the following line of code and any others to do with UIWindow:

    self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];

    Just need to remove above line from AppDelegate.m file.

    0 讨论(0)
  • 2021-01-14 06:42

    Make sure you enable the device orientations in the project's General settings

    in xcode 6.1, click your main project folder, General tab

    Scroll down to Device Orientation, enable "Portrait", "Landscape Left", "Landscape Right"

    See iOS 8.1 auto rotation for a picture of the Device Orientation settings

    0 讨论(0)
  • 2021-01-14 06:43

    I think your code is correct and you are seeing one (of many) bugs of XCode 6.1.

    I tried a very simple app with 6.1 using your code and I could experiment the bug. Then I downgraded to 6.0.1 and the autorotation of my app was perfect.

    I advice you to downgrade to XCode 6.0.1 and retry your app.

    You can download it from here: Apple Downloads

    0 讨论(0)
  • 2021-01-14 06:45

    Marked answer is to downgrade to XCode 6.0.1 - I do not recommend it.

    1) If you do not use storyboards (Answer for this topic !!)

    Go to -> Project Name -> Targets -> Project Name -> Deployment Info -> Main Interface -> Make it Empty


    2) In case you use storyboards (not the main answer)

    your AppDelegate should look like ...

    func application(application: UIApplication, didFinishLaunchingWithOptions launchOptions: [NSObject: AnyObject]?) -> Bool 
    {
        return true
    }
    
    0 讨论(0)
提交回复
热议问题