Question

I want to present a UIViewController with a UIView on top of my application wherever I am in the application. I want to add this to the UIWindow as a hud view. Is this possible? How should I start approaching this?

Was it helpful?

Solution

You might be able to do this with a UIWindow, but it's hard to get right, especially if you need the user to be able to interact with both windows at a time. The newer, better way to do this (if you're willing to target iOS 5) is to use the new view controller containment APIs.

You create a root view controller that hosts two sub controllers: one for the HUD, one for the main content. The root view controller then positions them on top of each other, and you can interact with either.

Another alternative is to use a raw UIView in your (main) UIWindow directly (placed above your normal view controllers), without a UIViewController. This works if you're willing to give up the convenience of using a view controller (such as callbacks on rotation, nib loading, memory warnings, etc.). To do this, just add your view as a subview of your main window.

OTHER TIPS

Have a look at my answer here: https://stackoverflow.com/a/4960988/202451

It should bring you closer to doing custom things like that :)

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