Keep UIView alway on top in app?

cocoa-touch, ios, iphone

Solution

You can have 2 windows in an application. But it is simply not recommended and we should avoid using multiple windows if we can. You can add a view on top of everything as a subview of the UIWindow as follows

[[UIApplication sharedApplication].keyWindow addSubview:viewName];

which should be not use often but you can have a view at the top of the view hierarchy by bringing it to the front as

[self.view bringSubviewToFront:viewName];

which brings the view to the front.

Problem

Is it possible to keep a UIView on top of everything else in an app, even modals etc.? Could it be done by having two UIWindows maybe or is there a recommended way of doing this?

Original source