navigation 自定义返回按钮手势返回实效解决

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

    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;

 

posted @ 2016-06-15 10:06  谢小锋  阅读(429)  评论(0编辑  收藏  举报