How to add a global right bar button (UINavigationController) in Three20's AppDelegate

前端 未结 2 655
余生分开走
余生分开走 2021-01-07 13:52

I want to add a global right bar button in the global AppDelegate so all my view controllers will have this button automatically.

I added in the AppDelegate

2条回答
  •  南方客
    南方客 (楼主)
    2021-01-07 14:20

    What you need to do is to tap into the navigation controller you wish to hook into. then you can implement UINavigationControllerDelegate (each navigation controller has a delegate property) which will give you these events:

    // Called when the navigation controller shows a new top view controller via a push, pop or setting of the view controller stack.
    - (void)navigationController:(UINavigationController *)navigationController willShowViewController:(UIViewController *)viewController animated:(BOOL)animated;
    - (void)navigationController:(UINavigationController *)navigationController didShowViewController:(UIViewController *)viewController animated:(BOOL)animated;
    

    You can implement

    - (void)navigationController:(UINavigationController *)navigationController willShowViewController:(UIViewController *)viewController animated:(BOOL)animated;

    and put your right button in place.

提交回复
热议问题