Prevent the animation when clicking “Back” button in a navigation bar?

后端 未结 5 1352
自闭症患者
自闭症患者 2020-12-14 09:16

My application has a navigation controller and I don\'t want any animation in it :

  • to prevent an animation when pushing a view, it\'s easy, via the pushView

5条回答
  •  臣服心动
    2020-12-14 09:53

    Not that you should, however you can override the standard behaviour by creating a custom leftBarButtonItem in your viewController.

    UIBarButtonItem *item = [[UIBarButtonItem alloc] initWithTitle:@"Back" style: UIBarButtonItemStylePlain target:self action:@selector(backButtonPressed)];
    [[self navigationItem] setLeftBarButtonItem:item];
    [item release];
    
    - (void)backButtonPressed
    {
        [[self navigationContoller] popViewControllerAnimated:NO];
    }
    

    The documentation says that you should only pass NO before the nav controller's view is displayed.

    Remember that applications that do not conform to the iPhone Interface Guidelines will not be accepted into the app store.

提交回复
热议问题