Fix for getting correct window.

At the moment the UIWindow could be an UIAlertView, which can't have a subview.
Now instead of the UIAlertView the correct window is used.