开发者

how to create a top bar shared among multiple views in navigationcontroller

What I need: I am working on an iPad application. I need a static top bar that should always appear on top, this top bar has several buttons. Regardless of which views I am showing, that top bar will always be there.

What I tried:

  • I want to control my views using navigation view controller. At first I tried to hide my navigation bar, and then i push views using a navigation controller. I tried to see if I can achieve an effect where a top bar is always stuck on top while I push views below. But failed. Navigation controller always pushes a view to take over the entire screen.

  • Giving up, I also tried to use navigation bar it self as a top bar (although the original design doesnt really expect a navigation bar), But I realize, when i created multiple bar buttons in the mainviewcontroller, all those buttons disappear when a new view controller is pushed, this make sense but again, this defeat my purpose as I want a static top bar that constantly shows the same buttons.

How can I achieve this? (use navigation controller to push views while having 开发者_JAVA技巧a shared top bar)


Use a UIToolbar to create a bar at (0,0,320,44), and add it on top of your window. You can make any buttons on this bar, and define them in the App delegate. And then, decrease the frame height of your window to fit the device you are targeting and add your rootViewController as a subview to your window.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜