简体   繁体   English

UIButton和在UITableViewCell上滑动删除

[英]UIButton and swipe-to-delete on UITableViewCell

I have a custom UITableViewCell with a UIButton. 我有一个带有UIButton的自定义UITableViewCell。 UIButton blocks the swipe-to-delete gesture recognizer implemented by Apple; UIButton阻止Apple实施的滑动删除手势识别器; if the swipe starts on the button, the swipe is not recognized, otherwise the delete button appears and everything works correctly 如果在按钮上开始滑动,则无法识别滑动,否则将显示删除按钮,并且一切正常

At the moment, I have replace the UIButton by an UIImageView to get the desired behaviour. 目前,我已将UIButton替换为UIImageView以获得所需的行为。

I would like if somebody manages to make this work. 我希望有人设法完成这项工作。

I have already tried to implement this delegate method 我已经尝试实现此委托方法

-(BOOL)gestureRecognizer:(UIGestureRecognizer *)gestureRecognizer shouldRecognizeSimultaneouslyWithGestureRecognizer:(UIGestureRecognizer *)otherGestureRecognizer 

and searched the view/subviews for all its gesture recognizers and assign them the cell as delegate. 并在视图/子视图中搜索其所有手势识别器,并将其分配为代表。 I still can make it work with a UIButton. 我仍然可以使其与UIButton一起使用。

I target ios8 我针对ios8

Thanks 谢谢

使用UILable或UIImage代替UIButton,并将userInteractionEnabled设置为YES,并向其中添加UITapGestureRecognizer手势。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM