在自定義返回按鈕的時(shí)候,側(cè)滑手勢返回往往默認(rèn)失效了秩冈,怎么讓側(cè)滑有效呢
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;