How to reference THE UIWindow from sub UIViewControllers?

Posted by maralbjo on Stack Overflow See other posts from Stack Overflow or by maralbjo
Published on 2010-06-16T11:03:00Z Indexed on 2010/06/16 11:12 UTC
Read the original article Hit count: 293

Filed under:

I am trying to add another subview programmatically based on some event (user taps a button, for instance).

My problem is that I am having problems referencing the (one and only) instance of UIWindow. I reach it from my appDelegate, because the MainWindow.xib and the appDelegate have been wired up. But I cannot reach the UIWIndow from anywhere else (I cannot draw that connection in IB, can I?)

What techniwue is preferred to get a reference to (the one and only) UIWindow? ...so that I in turn can use the following code from my various UIViewControllers:

[myOneAndOnlyWindow addSubview:oneOfManyViews.view];
[myOneAndOnlyWindow makeKeyAndVisible];

© Stack Overflow or respective owner

Related posts about iphone