【问题标题】:Passing touches to parent view controller after finish of Gesture recognizer手势识别器完成后将触摸传递给父视图控制器
【发布时间】:2012-05-01 04:27:55
【问题描述】:

我在 UIView 上添加了 UILongPressGesture,它是 UIScrollView 的内容,而 UIScrollView 在我的 RootViewController 中。

当 longPress 被识别时,我想调用我的 RootViewController 的 touches started 方法。 意味着我希望在我的 RootViewController 中长按时得到通知。

这是我的层次结构: RootViewController - CustomScrollView - ContentsViews

ContentsViews 有 longPressGestures ,当我们得到长按手势时,我想调用 RootViewController 的触摸开始,而不用抬起我已经触摸屏幕进行长按的手指。

【问题讨论】:

    标签: objective-c ios uiscrollview uitouch


    【解决方案1】:

    我也做过同样的事情, 调用我的父视图控制器的方法。 您只需引用 View Controller。

    喜欢, 在您的手势识别方法中。

    [(RootViewController*)contentsView.superview.superview touches began method];
    

    这样就可以调用了

    或者

    • 在 contentsView 中创建一个委托

      将你的 rootviewController 分配给它。

      修改一个touchesbegin的名字为touches started 1

      并调用根视图控制器的那个方法。

    【讨论】:

    • 实际上我得到了长按手势识别,我从滚动视图中删除 ContentsViews 并同时将其添加到 rootViewcontroller 上,这样我就可以在 RootViewController 上移动到我想要的任何位置,那么我该如何回电对于在 rootview 中移动的触摸 .??
    • 想想如果你的 touches started 方法是在内容视图上,那么无论你在哪里移动内容视图,你仍然可以再次唤醒它的 touches 移动方法。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2014-08-14
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2013-11-04
    • 2015-06-26
    • 2018-08-19
    相关资源
    最近更新 更多