Static Title/Navigation Bar?
I am new to iphone development. My application uses the tab bar as its main navigation mechanism. I simply want to display a static titl开发者_开发知识库e (navigation?) bar at the top of each screen, showing my company logo and no other text.
What is the best way to achieve this? Do I need to subclass NavigationBar?
Thank you!
UITabBarController
kind of insists on grabbing the whole screen, so each tab will need to display its own instance of your title strip (At least, that's the path of least resistance. There are ways to force a single view to stay on top of all the tabs but they're more work.)
Two basic approaches, one with a minor variation:
UITabBarController
contains nUINavigationController
s, each of which contains one of your VCs as its root view controller. Each of these has aUINavigationItem
with a custom title view containing your logo. Using aUINavigationController
purely for its titlebar-ness is a totally apple-encouraged pattern; and if they ever need to, your VCs will be able to do navigation pushes easily.UITabBarController
contains your VCs directly; then (as mentioned in the comment above) each of those contains aUIToolbar
somewhere in its own nib layout, probably across the top. Populate it however you like, probably with aUIBarButtonItem
with a custom view, surrounded with flexible space items if you want it centered. Good/bad feature: your logo is actually a button if you do it this way.Same as 2, but with a
UINavigationBar
laid out similarly.UINavigationBar
s can be used "naked" without aUINavigationController
. Shouldn't need to subclass it, just stuff a navigationItem with a custom title view in there. This gives you centering and a textual title for free if you want 'em, and avoids the button behavior.
精彩评论