Re: [iPhone] can't get views not to slide off by the height of the status bar
Re: [iPhone] can't get views not to slide off by the height of the status bar
- Subject: Re: [iPhone] can't get views not to slide off by the height of the status bar
- From: Matt Neuburg <email@hidden>
- Date: Tue, 25 Jan 2011 02:04:52 -0800
On Mon, 24 Jan 2011 22:36:51 -0200, WT <email@hidden> said:
>Hello list,
>
>I have the following view hierarchy in an iPhone test app:
>
>window
> status bar
> view managed by a tab bar with 2 tabs
> view for tab 0: some view, managed by some view controller
> view for tab 1: one of a set of views, managed by a navigation controller
> tab bar
>
>In more detail, MainWindow.xib has a UIViewController (tabBarVC) masquerading as a UITabBarController, that is, the view it's responsible for has a UITabBar along with a "content" view (held by an ivar called 'dataView') which is where the tab bar puts the contents of each tab.
>
>[ Yes, I know I could (and possibly/probably should) use a bona-fide UITabBarController but I need to be able to manipulate the tab bar in some ways, which is something you can't do with the tab bar attached to a tab bar controller. Regardless of the wisdom (or lack thereof) of this design, the problem I'm having is not due to using a stand-alone tab bar, as you'll see in a moment. ]
>
>The view managed by tabBarVC is loaded from a nib file (TabBarVC.xib) and contains the view itself (with the tab bar and dataView as subviews) and two view controllers, one for each tab (SomeVC and NavVC). The views they manage (some view and the root view for the navigation controller) are loaded from separate nib files.
>
>It's all very straight-forward, actually
No, it's not. What you're doing is very thoroughly illegal, which is why you're getting strange results. You can't use view controllers this way. A view controller is for the view that backs the whole view structure, the root view of the window. In addition, certain special built-in view controllers and other controllers can accept a view controller which they then own and "contain" and use to produce their view. But your root view is not controlled by that sort of view controller - it isn't a UITabViewController. So it cannot obtain its views by way of "contained" view controllers.
This explains the incorrect positioning of the views - a view loaded by a view controller thinks it will be the root view, in the window, so it allows 20 pixels for the status bar (the top 20 pixels of the window are behind the status bar). But this is merely symptomatic. It's lucky it happened, since you'd be in deep trouble if you want further down this road. Back off now and start over. You can certainly swap views into your interface on demand; but then just *do* it, without the spurious view controllers. If you want to keep those views in nibs in order to save memory until you need them, fine, but you'll have to load those nibs yourself and extract the views from them yourself and manage those views yourself.
m.
--
matt neuburg, phd = email@hidden, <http://www.apeth.net/matt/>
A fool + a tool + an autorelease pool = cool!
AppleScript: the Definitive Guide - Second Edition!
http://www.apeth.net/matt/default.html#applescriptthings_______________________________________________
Cocoa-dev mailing list (email@hidden)
Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden