0

次のコードを使用して、コンポーネントで UIPanGestureRecognizer をセットアップします。

MyComponent *c =[super newWithView:{
  [UIView class],
  {
    {
      CKComponentGestureAttribute(
      [UIPanGestureRecognizer class],
      &setupPanRecognizer,
      @selector(panGesture:context:),
      {}
      )
    },
    {
      @selector(setUserInteractionEnabled:), @YES
    }
  }
  }
  component: [MyOtherComponent newOtherComponentWithMode:model context:context]];

panGesture:contextMyComponentController オブジェクトで処理します。

私の問題は、UIPanGestureRecognizerフィード ビューのスクロールをブロックすることです。これを修正するために、UIGestureRecognizerDelegateプロトコルを使用して、両方 (スクロール ビューとパン) の認識機能を同時に動作させたいと考えています。

私の質問は、コンポーネントコントローラーをデリゲートとして割り当てるにはどうすればよいUIPanGestureRecognizerですか? setupPanRecognizerは単なる であり、オブジェクトやコンポーネント自体C functionへの参照さえありません。MyComponentController

私が今見ている唯一の方法は、コントローラーのメソッドのどこかでジェスチャ認識機能のリストを取得しdidUpdateComponent、正しいものを見つけてそこにデリゲートを割り当てることです。ComponentKit はこれに対する解決策を提供しますか?

4

1 に答える 1

1
CKComponentViewAttributeValue CKComponentGestureAttribute(Class gestureRecognizerClass,
                                                      CKComponentGestureRecognizerSetupFunction setupFunction,
                                                      CKComponentAction action,
                                                      CKComponentForwardedSelectors delegateSelectors)

最後に「delegateSelectors」引数を見つけることができるので、コントローラーで応答したいセレクターのベクトルを渡すことができます。

于 2016-01-02T13:46:28.687 に答える