iOS定义自己的回报button(它不影响返回手势)

时间:2022-12-08 19:07:20

这种方法可以定义为返回到其button,它不影响返回手势。

新方法:

 self.navigationItem.leftBarButtonItem = [[UIBarButtonItem alloc]
initWithImage:img
style:UIBarButtonItemStylePlain
target:self
action:@selector(onBack:)];
self.navigationController.interactivePopGestureRecognizer.delegate = (id<UIGestureRecognizerDelegate>)self;

老方法:

    UIBarButtonItem *backButton = [[UIBarButtonItem alloc] initWithTitle:@"" style:UIBarButtonItemStylePlain target:self action:nil];
self.navigationController.navigationBar.topItem.backBarButtonItem = backButton;