【问题标题】:UIView's touches not being recognizedUIView 的触摸不被识别
【发布时间】:2012-07-11 07:06:45
【问题描述】:

touchesBegan: 没有被我的TextSelection 类调用。 TextSelection 是一个 UIView 子类,我将它添加为 ReaderContentPage 的子视图,也是一个 UIView。 ReaderContentPageReaderContentView 的子视图,一个 UIScrollView。而这个ReaderContentViewReaderViewController 内部,一个UIViewController。为了便于理解,这里有一个插图。

现在我的问题是这个。 touchesBegan:touchesMoved: 在 TextSelect 中无法识别。我启用了 userInteraction,使用了 UIPanGestureRecognizer,但这些都不起作用。现在,当我尝试这样做时:[self.ReadContView addSubView:txtSel] 而不是这个[self.ReadContView.ReadContPage addSubView:txtSel],触摸被识别。但是由于某种原因,我必须将它添加到 ReaderContentPage 而不是 ReaderContentView 中。那么,任何人都可以向我解释为什么当我在 ReaderContentPage 中添加 TextSelect 时没有调用 touchesBegantouchesMoved 吗?

【问题讨论】:

  • 是否也为 readcontpage 启用了用户交互?
  • 嗯,没有任何声明。 userInteraction 是否默认禁用?我会启用它,看看它是否能解决我的问题。

标签: ios cocoa-touch uiview touchesbegan


【解决方案1】:

在 UIImageView 上默认禁用 UserInteraction,你的 readContentPage 中有 UIImageView 吗?

【讨论】:

  • ReaderContentPage 中没有 UIImageView,但是里面禁用了 userInteraction。我将 userInteraction 声明为已启用,它最终识别了触摸。谢谢!
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2011-02-14
  • 1970-01-01
  • 1970-01-01
  • 2023-04-03
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多