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, except that both tabs display 20 
pixels below the bottom of the status bar - please see the picture. Clearly, 
this is a problem of setting the appropriate auto-resizing masks for views and 
the various other related properties.

And that's where I'm stuck. I already tried all options that I think make sense 
but I'm obviously missing something (read: a better grasp of the conditions 
under which sizes and positions get set and changed by IB when I'm not looking).

Here's what the properties are for the pictures in question:

In MainWindow.xib, the tabBarVC has the "resize view from NIB" selected and a 
status bar set in the simulated UI elements panel.

In TabBarVC.xib, both view controllers and the root view controller of the 
navigation controller all have the "resize view from NIB" selected. SomeVC has 
a status bar and a tab bar in the simulated UI elements panel while NavVC has 
those as well as a navigation bar. The view in this nib has a status bar in the 
simulated panel, scale to fill for its mode, autoresize its subviews, (0, 0, 
320, 460) for its frame, and top and left anchors for its autosizing mask.

The dataView subview (it's red in the pics) has scale to fill and autoresize 
its subviews both selected, (0, 0, 320, 411) for its frame, and a full 
autosizing mask (all anchors and both horizontal and vertical stretchers).

The views in NavRootVC.xib and SomeVC.xib both have scale to fill, autoresize 
subviews, top and left anchors, and status bar and tab bar in the simulated 
panel. The view in SomeVC.xib has a frame (0, 0, 320, 411) and the view in 
NavRootVC.xib has (0, 0, 320, 367) and a navigation bar set in the simulated 
panel.

Incidentally, according to the docs, the simulated UI elements panel has no 
actual effect on any object saved in the nib but that's not entirely true since 
view sizes get changed when you set those simulated elements and those view 
sizes are saved along with the view, aren't they?

To summarize, I'm puzzled because both subviews of dataView are sized correctly 
but positioned incorrectly, despite the fact that their autosizing masks are 
set to anchor them at their top positions and both of them have their top 
positions set to vertical zero. Somewhere, something is deciding to slide (by 
the height of the status bar) any view added as a subview of dataView. I just 
can't see where that is happening. I NSLogged the frame of any view added as a 
subview to dataView and, sure enough, it has its vertical top set to 20 before 
it's added as a subview, so it's been changed from the vertical zero displayed 
by IB even before its superview-to-be has a chance to change its frame.

More than just a "do X to fix it" I'd greatly appreciate some insight on why 
this is happening (beyond the obvious "because views need to be resized and 
repositioned to fit the space they're allotted to by their view controllers"). 
This isn't my first time getting frustrated by IB's propensity to 
resize/reposition views when no one is looking and the docs haven't been 
particularly helpful in this regard. I'm sure I'm not alone in this, either.

If you feel up to playing with the test app, its project can be downloaded from 
here: http://www.restlessbrain.com/NavTest.zip

Thank you in advance for any help and apologies for the long message.
WT

<<inline: tabs.png>>

_______________________________________________

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

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:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

Reply via email to