开发者

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 n UINavigationControllers, each of which contains one of your VCs as its root view controller. Each of these has a UINavigationItem with a custom title view containing your logo. Using a UINavigationController 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 a UIToolbar somewhere in its own nib layout, probably across the top. Populate it however you like, probably with a UIBarButtonItem 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. UINavigationBars can be used "naked" without a UINavigationController. 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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜