1

In the view programming guide for iOS, it states "Every iOS application needs at least one window—an instance of the UIWindow class—and some may include more than one window."

What are some examples Apps that would need more than one window?

Thanks

mskw
  • 10,063
  • 9
  • 42
  • 64

2 Answers2

1

Apps that require to output video to a second screen might use more than one window. Here you have a question about that particular topic.

You could also use more than one window to achieve other objectives, but that is not recommended by Apple. In general if you see that you need 2 windows or more, I'd suggest that something is wrong with your approach.

I've played around with 2 windows to integrate cocos2d and uikit in a test project, the code was pretty clean and the idea was to switch between windows, using the visibility and the key window, as necessary. It worked, but sometimes when sending the app to background, for some magical reason the active, key window would be made invisible.

Community
  • 1
  • 1
Lio
  • 4,225
  • 4
  • 33
  • 40
0

Afaik the only case you'd need more than one window is if you connect another screen like a TV to your device. In that case you could provide a totally independent UI for the second screen. F.e. the Keynotes app on iPad does that when you connect another screen to the device.

You could register for the UIScreenDidConnectNotification and handle it like this:

- (void)screenDidChange:(NSNotification *)notification
{
    if ([UIScreen screens] count] > 1)
    {
        UIScreen *extScreen = [[UIScreen screens] objectAtIndex:1];
        UIWindow *extWindow = [[UIWindow alloc] initWithFrame:[extScreen bounds]];
        //add some subviews to the window
        extWindow.screen = extScreen;
        [extWindow makeKeyAndVisible];
    }
}
Tobi
  • 5,499
  • 3
  • 31
  • 47