【问题标题】:Passing scroll gesture to UIScrollView from another view从另一个视图将滚动手势传递给 UIScrollView
【发布时间】:2010-09-15 19:05:55
【问题描述】:

我确实有一个具有 UIScrollView 的视图,并且在它上面有一个显示一些文本的视图。 当用户在包含文本的视图上滑动时,UIScrollView 不会滚动。如何以将滑动手势传递给 UIScrollView 的方式使该视图透明。

谢谢

【问题讨论】:

    标签: iphone uiscrollview gesture uigesturerecognizer swipe


    【解决方案1】:

    你可以设置

    myTextView.userInteractionEnabled = NO;
    

    或者,如果您使用 Interface Builder 创建视图,那里有一个名为“启用用户交互”的复选框,只需取消选中即可。

    【讨论】:

    • 这将禁用该文本视图中的按钮。它有一个幻灯片播放/停止按钮。
    【解决方案2】:

    查看UIView hitTest Method

    返回包含指定点的视图层次结构(包括其自身)中接收器的最远后代。

    - (UIView *)hitTest:(CGPoint)point withEvent:(UIEvent *)event
    

    【讨论】:

      【解决方案3】:

      在自定义视图的 -touchesXXXX:withEvent: 方法中,调用它们的超级方法来转发触摸事件。

      例如:

      - (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event
      {
        // forward touchesBegan to super class
        [super touchesBegan:touches withEvent:event];
      
        ... 
        // process touchesBegan for this view
      } 
      

      对 touchesMoved、touchesEnded 和 touchesCancelled 执行相同的操作。

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 2015-10-26
        • 1970-01-01
        • 1970-01-01
        • 2014-01-22
        • 1970-01-01
        • 1970-01-01
        • 2011-04-13
        • 1970-01-01
        相关资源
        最近更新 更多