4

I'm coding a video processing app and was just about to submit it to the app store when ios 8.1 came out. I updated my iPhone as well as XCode and all hell broke loose. In my simple single viewcontroller interface nothing is rotating anymore except for the statusbar, which also doesn't get automatically hidden anymore in landscape mode...

I figured it was because I was using the deprecated willAnimateRotationToInterfaceOrientation: for what little custom rotation actions I had, so I implemented traitCollectionDidChange: and viewWillTransitionToSize: to specs instead. However viewWillTransitionToSize never gets called in my app and traitCollectionDidChange: is only called once, at startup. The device simply isn't telling the app that the device has rotated.

After googling I've also tried using name:UIDeviceOrientationDidChangeNotification. At least my selector does get called for that one but I don't know how to manually handle all rotation.

My didFinishLaunching... and viewDidLoad are very simple. alloc UIWindow, storyboard, set my viewcontroller from there, make it rootviewcontroller, makekeyandvisible. All based on one of Apple's AVFoundation demo apps. Then in didload I add some subviews and a toolbar etc, nothing out of the ordinary and obviously it did work on 8.0 and 8.0.2 on all kinds of devices as well as the 7.1 simulator etc. Still runs flawlessly on my iPad with 8.0.2... Reason I haven't posted any code is I'm 100% sure everything is correct on that end.

Main weird thing is I can't seem to find anyone with this problem. No errors in console or elsewhere either.

Does anyone have any idea of what might be causing this? I didn't think a point release would make such massive differences and again, no one else seems to be having this. Could it be an issue/bug in the actual storyboard file?

And, mainly, since I can get rotation notifications through UIDeviceOrientationDidChangeNotification, how do I manually handle all rotation/resizing stuff? I have been looking all over for answers but to no avail and am out of time to spend on this project currently :(

Cheers!

tolgraven
  • 528
  • 5
  • 11

1 Answers1

6

alloc'ing UIWindow will be the problem.

First, Make sure your navigation controller (or whatever you're using) is set as "Initial View Controller" in your storyboard.

Secondly, in your AppDelegate.m file, remove any references to UIWindow and rootViewController that appear in application didFinishLaunchingWithOptions. In my case, removing the following two lines fixed my issues.

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

You also don't need to set the window's rootViewController if using storyboards.

They're simply not needed when using storyboards, but until 8.1 there was never any harm using them. It took my 2 days to figure this out, so hopefully it will help you and others too.

ChrisJP
  • 975
  • 1
  • 7
  • 15
  • BRILLIANT MATE! So basically it's a question of the storyboard being initialized automatically and us then redoing that manually - treating a storyboard like a xib and then the new window somehow doesn't receive the stuff it – tolgraven Oct 24 '14 at 23:00
  • 2
    Yes, to quote an Apple support staffer: "The window created by the system, being the first window, receives orientation change notification first. Due to a change in iOS 8.1, the first window ends up blocking the second window (the one you created, the key window) from responding to the orientation change." Be sure to accept this as an answer if it solved your problem ;) – ChrisJP Oct 25 '14 at 12:07
  • Thank you, this did the trick for me. You've saved me countless amounts of time. In my case I needed to keep a reference to rootViewController because I'm using an initial view controller in a CocoaPod, but removing the references to UIWindow fixed it! – Shawn Aukstak Nov 04 '14 at 17:39