Georg Georg - 1 month ago 5
iOS Question

iOS state restoration animation bug

I just wanted to implement the iOS State-Restoration APIs in one of my Apps.
After finally getting it to work, I discovered that a ViewController that I present modally gets restored using an animation, which is not what I want. I would expect my app to just be in the state I left it, but not having the user to see hot he got there.

So I went ahead and downloaded Apple Sample Code on that: https://developer.apple.com/library/ios/samplecode/StateRestore/Introduction/Intro.html and wanted to see if it happens there as well. And it turns out that it does.

Further there is a warning in the Logs:

Unbalanced calls to begin/end appearance transitions for <UINavigationController: 0x7b0512b0>.


Can you tell me if I and obviously Apples Sample Code are doing something wrong, or if it's a bug in iOS?

Btw. I was testing on iOS8

Thanks for any help,
Georg

Answer

The following solution comes directly from Apple.

In your app delegate, you should be implementing application:willFinishLaunchingWithOptions: (instead of or in addition to didFinishLaunching). In your implementation, probably as the last line just before returning true (or YES if this is Objective-C), insert this line:

self.window?.makeKeyAndVisible()

Or, if this is Objective-C:

[self.window makeKeyAndVisible];

It turns out that this was always needed, but the documentation has never been clear about it.