Fergal Rooney
Fergal Rooney

Reputation: 1390

iOS 5 UIWindow makeKeyAndVisible closes modal

I have a scenario where I present a modal view controller from the main window's rootViewController. While it is loading the contents of this modal, I am switching to another loading window which I make key and visible.

This window acts as a loading indicator and does not allow the user to interact with the app. When it is done loading, I switch back to the main window by making it key and visible. When I do this, the modal is force closed and the app is no longer able to present modals.

Interestingly enough, if I execute [UIWindow makeKeyWindow] when switching back to the main window, there are no issues. [UIWindow makeKeyAndVisible] is what's causing the issue. Is [UIWindow makeKeyWindow] an acceptable alternative?

This is iOS 5 only. No issues in iOS 6. I am not supporting iOS 4. Does anyone know what might be happening here?

Upvotes: 6

Views: 1838

Answers (2)

Denis Mikhaylov
Denis Mikhaylov

Reputation: 2045

It is definetly bug in iOS 5 UIWindow implemetation. I faced this strange behaviour and Aleksey's answer is the way to go.

Upvotes: 0

Alexey Kozhevnikov
Alexey Kozhevnikov

Reputation: 4259

I got the same behaviour, and as documentation states that makeKeyAndVisible method is a convenience method it seems to me legit to substitute makeKeyAndVisible call with working code:

[window makeKeyWindow];
window.hidden = NO;

Have no idea what's wrong, but it looks like a bug.

Upvotes: 6

Related Questions