我使用下一个代码在我的组件中设置 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/