如何使用UIGestureRecognizerDelegate?

时间:2015-06-26 22:08:06

标签: ios swift uiview uiscrollview uipangesturerecognizer

我的设置

我试图复制Google即时的卡片界面。

我有一个UIView,它是(内部)UIScrollView的子视图。两者都是从同一UIViewController控制的。 UIView附加了UIPanGestureRecognizer UIViewController

UIScrollView用于向上和向下滚动。 UIPanGestureRecognizer用于刷掉UIView

问题

我在触摸UIView(卡片)时无法滚动

问题

如何实施UIGestureRecognizerDelegate以启用卡上的gestureRecognizer(_:shouldRecognizeSimultaneouslyWithGestureRecognizer:),以便让UIScrollView滚动?

我花了几个小时试图解决这个问题,我非常感谢你的帮助。

1 个答案:

答案 0 :(得分:6)

如果有人想知道如何做到这一点,请回答:

声明类时,在类子类之后添加(defn measurement-input [{:keys [amount unit path]}] (let [amt (atom amount)] (fn [] [:div [:input {:type "text" :value @amt :on-change #(do (reset! amt (-> % .-target .-value)) ;; argument literal, %, is the event passed in the function callback (re-frame/dispatch [:update-value @amt [:measurements path :amount]]))}] [:input {:type "button" :value unit}]]))) 。这就是我的情况:

UIGestureRecognizerDelegate

接下来,将此函数添加到class CardViewController: UIViewController, UIGestureRecognizerDelegate

的正文中
UIViewController

最后,您对func gestureRecognizer(gestureRecognizer: UIGestureRecognizer, shouldRecognizeSimultaneouslyWithGestureRecognizer otherGestureRecognizer: UIGestureRecognizer) -> Bool { return true }

执行此操作

UIPanGestureRecognizer