self.navigationItem.backBarButtonItem = [[UIBarButtonItem alloc] initWithTitle:@"王俨" style:UIBarButtonItemStylePlain target:nil action:nil];
@interface ViewController ()
@end@implementation ViewController
- (void)viewDidLoad {
[super viewDidLoad]; // 自定义返回按钮
UIButton *button = [[UIButton alloc]initWithFrame:CGRectMake(0, 0, 44, 44)];
[button setTitle:@"王俨2" forState:UIControlStateNormal];
[button setTitleColor:[UIColor blackColor] forState:UIControlStateNormal];
[button addTarget:self action:@selector(back:) forControlEvents:UIControlEventTouchUpInside]; self.navigationItem.leftBarButtonItem = [[UIBarButtonItem alloc]initWithCustomView:button];
}
- (void)back:(UIButton *)button {
[self.navigationController popViewControllerAnimated:YES];
}
- (void)viewWillAppear:(BOOL)animated {
[super viewWillAppear:animated]; if (self.navigationController.viewControllers.count > 1) { // 记录系统返回手势的代理
_delegate = self.navigationController.interactivePopGestureRecognizer.delegate; // 设置系统返回手势的代理为当前控制器
self.navigationController.interactivePopGestureRecognizer.delegate = self;
}
}
- (void)viewWillDisappear:(BOOL)animated {
[super viewWillDisappear:animated]; // 设置系统返回手势的代理为我们刚进入控制器的时候记录的系统的返回手势代理
self.navigationController.interactivePopGestureRecognizer.delegate = _delegate;
}#pragma mark - UIGestureRecognizerDelegate- (BOOL)gestureRecognizerShouldBegin:(UIGestureRecognizer *)gestureRecognizer { return self.navigationController.childViewControllers.count > 1;
}
- (BOOL)gestureRecognizer:(UIGestureRecognizer *)gestureRecognizer shouldRecognizeSimultaneouslyWithGestureRecognizer:(UIGestureRecognizer *)otherGestureRecognizer { return self.navigationController.viewControllers.count > 1;
}@end
机械节能产品生产企业官网模板...
大气智能家居家具装修装饰类企业通用网站模板...
礼品公司网站模板
宽屏简约大气婚纱摄影影楼模板...
蓝白WAP手机综合医院类整站源码(独立后台)...苏ICP备2024110244号-2 苏公网安备32050702011978号 增值电信业务经营许可证编号:苏B2-20251499 | Copyright 2018 - 2025 源码网商城 (www.ymwmall.com) 版权所有