I have a "navigation based application" which also needs to have a view always displayed at the bottom of the screen at all times. I added this new view to a UIWindow after adding the UINavigationController's view:
// In my delegate's applicationDidFinishLaunching method
[window addSubview:navigationController.view];
[window insertSubview:disclaimerController.view aboveSubview:navigationController.view];
[window makeKeyAndVisible];
This works fine except for rotation. The second view I added doesn't rotate correctly. It doesn't change position and it's view controller's rotate methods don't get called.
Obviously, I'm going about this the wrong way. My question is, how can I have a second view on screen that's not part of navigation controller's view? Thanks.
Check out my answer here: https://stackoverflow.com/a/4960988/202451
It should bring you closer to doing custom things like that :)
If you add a view of another view controller as a subview to the active window of the application you must synchronize its
center
,bounds
andtransform
properties withwindow.rootViewController.view
. Also be sure your top view is added after correct initialization of the window, and also after its root subview has been added to it as a subview.I suppose this can be done in multiple ways, I've made it work through use of Key-value observing.
Here the
topViewController
is instance of aUIViewController
subclass and it represents the view controller of theUIView
that should be on top of the application windowAppDelegate.m
:topViewController
's.m
file:If you are adding a view on top of another by adding as subview rotation will not work (view won't be notified of rotation). What you can do is register the view with the device to be notified of rotation events, then you can programatically handle rotation (it will not do it for you).