【问题标题】:How to assign UIGestureRecognizerDelegate to CKComponentController如何将 UIGestureRecognizerDelegate 分配给 CKComponentController
【发布时间】:2016-03-01 12:20:16
【问题描述】:

我使用下面的代码在我的组件中设置 UIPanGestureRecognizer:

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

我在 MyComponentController 对象中处理panGesture:context

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

我的问题是如何将我的组件控制器分配为UIPanGestureRecognizer 的代表? setupPanRecognizer 只是一个C function,它没有引用MyComponentController 对象甚至组件本身。

我现在看到的唯一方法是在控制器的 didUpdateComponent 方法中的某处获取手势识别器列表,找到正确的并在那里分配委托。 ComponentKit 是否提供任何解决方案?

【问题讨论】:

    标签: ios objective-c componentkit


    【解决方案1】:
    CKComponentViewAttributeValue CKComponentGestureAttribute(Class gestureRecognizerClass,
                                                          CKComponentGestureRecognizerSetupFunction setupFunction,
                                                          CKComponentAction action,
                                                          CKComponentForwardedSelectors delegateSelectors)
    

    您终于可以找到“delegateSelectors”参数,因此您可以尝试传入一个您希望在控制器中响应的选择器向量。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2016-06-08
      • 2016-10-20
      • 2020-09-19
      • 2015-02-15
      • 2020-07-14
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多