您可以从此 libk 下载代码示例: https ://github.com/mriddi/ExempleCustomGestureRecognizer.git
我像这样创建我的自定义手势识别器类:
@protocol MyGestureRecognizerDelegate <UIGestureRecognizerDelegate>
@optional
-(void) willDo;
@end
@interface MyGestureRecognizer: UIGestureRecognizer
{
…
}
@property (nonatomic, assign) id <MyGestureRecognizerDelegate> delegate;
…
@end
@implementation MyGestureRecognizer
@synthesize delegate;
…
-(void) call{
[delegate willDo];
}
…
@end
我的 ViewController 采用MyGestureRecognizerDelegate
协议。在ViewController
我创建我的类的实例:
MyGestureRecognizer * grFerst;
MyGestureRecognizer * grSecond;
grFerst.delegate=self;
grLeft.delegate=self;
[self.view addGestureRecognizer: grFerst];
[self.view addGestureRecognizer: grSecond];
我想让两个手势识别器实例同时工作。我尝试添加到我的ViewController
方法中
shouldRecognizeSimultaneouslyWithGestureRecognizer
但是这个方法从不调用,我用NSLog
函数检查了它。
请帮我解决这个问题(允许同时使用两个手势识别器)。