iOS自定义返回按钮右滑返回手势失效

在自定义返回按钮的时候,侧滑手势返回往往默认失效了,怎么让侧滑有效呢

UIButton  *btn =[UIButton buttonWithType:UIButtonTypeCustom];

[btn setTitle:@"返回" forState:UIControlStateNormal];

[btn addTarget:self action:@selector(back) forControlEvents:UIControlEventTouchUpInside];

btn.frame=CGRectMake(0, 0, 60, 40);

[btn setTitleColor:[UIColor blackColor] forState:UIControlStateNormal];

UIBarButtonItem  *item =[[UIBarButtonItem alloc]initWithCustomView:btn];

self.navigationItem.leftBarButtonItem=item;

添加下面这一句代码即可

self.navigationController.interactivePopGestureRecognizer.delegate=(id)self;

你可能感兴趣的:(iOS自定义返回按钮右滑返回手势失效)