ios - 如何将 UIGestureRecognizerDelegate 分配给 CKComponentController

标签 ios objective-c componentkit

我使用下一个代码在我的组件中设置 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 阻止 feed View 滚动。为了解决这个问题,我想使用 UIGestureRecognizerDelegate 协议(protocol)并允许两个( ScrollView 和平移)识别器同时工作。

我的问题是如何将我的组件 Controller 分配为 UIPanGestureRecognizer 的委托(delegate)? setupPanRecognizer 只是一个 C 函数,它没有引用 MyComponentController 对象,甚至组件本身。

我现在看到的唯一方法是在 Controller 中的 didUpdateComponent 方法中获取手势识别器列表,找到正确的并在那里分配委托(delegate)。 ComponentKit 是否提供了解决方案?

最佳答案

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

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

关于ios - 如何将 UIGestureRecognizerDelegate 分配给 CKComponentController,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33954982/

相关文章:

ios - chartValueSelected 永远不会被调用

ios - 从 UIViewController 导航到 SwiftUI View

objective-c - iOS:NSMutableArray 为空

ios - 在 ComponentKit 中播放视频

ios - 如何配置组件的底层?

ios - 如何在关闭并重新打开应用程序时将导航堆栈上的当前 View 和所有以前的 View 显示为 "save"?

iOS - 从 UIAlertView 添加数据到 sqlite

objective-c - Objective-c 点符号或方括号符号中首选什么?

objective-c - 如何高效展示多张图片? (iPhone编程)

c++ - 如何右对齐第一个组件