展开右上角的快捷菜单按钮后,点击屏幕其他区域按钮没有自动收起

时间:2021-01-31 04:29:23

 //给界面添加了一个单击手势

    UITapGestureRecognizer *tap =[[UITapGestureRecognizeralloc]initWithTarget:selfaction:@selector(hiddenrightview:)];

    [self.viewaddGestureRecognizer:tap];

//进行逻辑判断

-(void)hiddenrightview:(UITapGestureRecognizer *)recogin{   

   self.view.hidden =YES;    

}

- (void)rightBtnClick{

    conditionview.view.hidden=!conditionview.view.hidden;

}



之前的这个代码会出现一点问题,如果定义的这个rightBtn里面还有cell,使用上述的代码会无法点击cell

现在代码更改如下:

UITapGestureRecognizer *tapGestureRecognizer = [[UITapGestureRecognizeralloc]initWithTarget:selfaction:@selector(hiddenrightview:)];

    tapGestureRecognizer.cancelsTouchesInView =NO;

    [self.viewaddGestureRecognizer:tapGestureRecognizer];


-(void)hiddenrightview:(UITapGestureRecognizer *)recogin{   

 

    [self.view endEditing:YES];

}


其实只是变更了一个手势的问题