Question

I got a problem with my applications keyWindow on iPad.

I designen my app for iPhone and added the iPad support later by setting the device family and adding a new storyboard for iPad. Everything is fine so far, I can open the app on the ipad and even the interface shows up as I customised it for iPad.

Now here comes the problem: I don't know why, but the iPad version of my app doesn't have a keyWindow. I need that because I display a loading dialog at the beginning that should lock the screen for user interaction, so I added it to the main window. On iPhone this works fine.

I figured out that "[UIApplication sharedApplication].keyWindow" gives me null, but only on iPad, whereat "[[UIApplication sharedApplication].windows objectForKey:0]" gives me the window object, which of course must exist because the app shows the complete ui.

The source files for ipad and iphone are, of course exactly the same, but I think I missed something when I added the iPad support later...

I already tried to set the window object in the application delegate to makeKeyAndVisible manually but with no luck. ([self.window makeKeyAndVisible];)

Does anyone has an idea what I have to do to make this working?

Kind regards

Was it helpful?

Solution

Ok I solved it myself. I had to apply the makeKeyAndVisible method to my main window where I want to access it as keyWindow. I don't know why it doesn't work in the Application Delegate or why I have to set it manually for iPad and not for iPhone at all, but it works now.

If anyone knows why feel free to enlighten me.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top