ios - UIScrollView 上的 UITapGestureRecognizer

标签 ios objective-c uiscrollview

我在 Storyboard的 UIScrollView 上设置了一个 UITapGestureRecognizer。 ScrollView 包含其他内容(两个 UIView,一个 UIWebView)。

手势识别器属性如下:

  • Action :dismissPopover
  • 委托(delegate):postViewController
  • gestureRecognizers: ScrollView
  • 状态:启用
  • 需要的 Taps 数量:1
  • 需要的 Touches 数:1
  • 取消TouchesInView:是
  • delayTouchesBegan:否
  • delayTouchesEnded:是

ScrollView (相关)属性如下:

  • userInteractionEnabled:是
  • canCancelContentTouches:是

但是,当我点击 ScrollView 上的任意位置时,手势不起作用。

最佳答案

委托(delegate)类(符合UIGestureRecognizerDelegate)必须实现

- (BOOL)gestureRecognizer:(UIGestureRecognizer *)gestureRecognizer shouldRecognizeSimultaneouslyWithGestureRecognizer:(UIGestureRecognizer *)otherGestureRecognizer
{
    return YES;
}

这样,点击手势就可以工作了。

关于ios - UIScrollView 上的 UITapGestureRecognizer,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27715448/

相关文章:

java - 客户端应用程序中本地存储管理和数据持久性的最佳实践是什么?

iphone - UIImageView 中的圆角

ios - ScrollView 中的动态高度 TableView

iphone - MKMapView 更改 View 中的物理位置

ios - 有没有办法让每次生成元素时都出现随机图像? ( objective-C )

ios - CATextLayer 中的 NSAttributedString 导致 EXC_BAD_ACCESS (ios 5.0)

java - 在客户端应用程序中声明 REST 服务 api 端点的正确模式?

ios - UIScrollView subview 的Redraw/setNeedsLayout不起作用

ios - 如何将MySQL数据库与objective-c项目连接?

ios - 自定义 UITableViewCell 重叠对象