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:context在 MyComponentController 对象中处理。

我的问题是UIPanGestureRecognizer阻止滚动提要视图。为了解决这个问题,我想使用UIGestureRecognizerDelegate协议并允许两个(滚动视图和我的平移)识别器同时工作。

我的问题是如何将我的组件控制器分配为代表UIPanGestureRecognizersetupPanRecognizer只是一个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 回答