标签:
自定义导航控制器,重写下面的方法,创建一个返回箭头按钮
1 - (void)pushViewController:(UIViewController *)viewController animated:(BOOL)animated 2 3 { 4 5 if (self.viewControllers.count > 0) { 6 7 // 隐藏返回按钮的文字 8 9 viewController.navigationItem.leftBarButtonItem = [[UIBarButtonItem alloc]initWithImage:[UIImage imageNamed:@"pull_left_btn"] style:UIBarButtonItemStyleDone target:self action:@selector(back)]; 10 11 } 12 13 [super pushViewController:viewController animated:YES]; 14 15 }
// 返回
1 - (void)back 2 3 { 4 5 [self popViewControllerAnimated:YES]; 6 7 }
但是这样会导致弹出手势失效所以需要在- (void)viewDidLoad中添加以下代码
- (void)viewDidLoad { [super viewDidLoad]; // 清空弹出手势的代理,就可以恢复弹出手势 self.interactivePopGestureRecognizer.delegate = nil; }
标签:
原文地址:http://www.cnblogs.com/iamjjh/p/4629142.html