简体   繁体   English

UIScrollView和UIButton在辅助事件冲突中进行补正

[英]UIScrollView and UIButton touch up in side event conflict

I hava a TableViewController, When I tap on a cell it pushed into a detail controller. 我有一个TableViewController,当我点击一个单元格时,它推入了一个细节控制器。 On the detail controller, I have a scrollview and a UIButton on it. 在详细信息控制器上,我有一个scrollview和一个UIButton。 I want single tap on the scrollview to back to TableView and touch the UIButton to do other things. 我希望在滚动视图上单击以返回TableView并触摸UIButton来执行其他操作。 In the detail controller: 在详细信息控制器中:

UITapGestureRecognizer *tapRecognizer = [[UITapGestureRecognizer alloc] initWithTarget:self action: @selector(singleTap:)];
tapRecognizer.cancelsTouchesInView = NO;
[self.scrollView addGestureRecognizer:tapRecognizer];

Now, when I tap the scrollview it back to tableview, but when I tap the UIButton, It also back to tableview, How to fix it? 现在,当我点击滚动视图时,它又回到了桌面视图,但是当我点击UIButton时,它又回到了桌面视图,如何解决? Thank you. 谢谢。

  1. A simple suggestion to make the tap with two fingers rather than a single finger. 一个简单的建议是用两个手指而不是一个手指来制作水龙头。
  2. Subclass the scroll view and implement it's touches methods. 子类化滚动视图并实现它的touchs方法。 If the touch area is the same as the button frame, return NO to the gesture delegate. 如果触摸区域与按钮框相同,则将NO返回给手势委托。 Button will take the touch. 按下按钮即可触摸。

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

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