开发者

iOS Custom Menu (Navigation Controller? )

开发者 https://www.devze.com 2023-04-04 09:06 出处:网络
I have an app planned out that needs to have a custom menu throughout the application. Its not a toolbar or anythi开发者_如何学Pythonng like that so i don\'t think a regular UINavigationController or

I have an app planned out that needs to have a custom menu throughout the application. Its not a toolbar or anythi开发者_如何学Pythonng like that so i don't think a regular UINavigationController or a UITabBarController will do the job.

What would be the best approach to creating this custom menu that appears in all views? I thought of just creating a view with the custom menu and alloc it for each view but it seems like a bit of an overkill. Extending UINavigationController might also be an option, but I'm not sure.

Would love to hear your opinions.

Thank you! :)

Shai.


The UINavigationController and the UITabBarController are pretty much always the best way to go because they have view and memory management built in. Here's what you can do:

  1. Create a subclass of UITabBarController that hides the tab bar. See the last post on this page: http://www.iphonedevsdk.com/forum/iphone-sdk-development/4091-uitabbarcontroller-hidden-uitabbar.html Make this UITabBarController accessible on a singleton object.
  2. Create a view for your menu and some IBActions corresponding to the menu buttons.
  3. When a menu button is pressed, you can manually switch the tabs of the uitabbarcontroller as follows: tabBarController.selectedIndex = x;


I agree with ade. I think a popover controller added to a shared class would fit best to the iOS style (I'd put it in AppDelegate in order to have reference to it from anywhere and to avoid creating multiple instances and using only one which you will keep displaying / hiding whenever you wish to see the menu)


I can think of two options: 1. Subclass UINavigationController, hide the standard UINavigationBar's view and create your own view and put it on top of it (ugly and who knows what the results will end up like). 2. Add the menu as a subview of UIWindow so it stays on top of everything throughout the app.


I think the best way is to create a custom tool bar and use it across the app. Subclassing UINavBar is another option but not recommended by Apple so I would not go there.


I'd look into using a popover style menu such as WEPopover

0

精彩评论

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

关注公众号