我想将UIPanGestureRecognizer
参数从onCViewPanned
方法传递给showFollowing
。
我试图通过UIGestureRecognizerStateBegan
但是,它没有接受它。我该如何解决这个问题?
-(void) showFollowing{
[self onCViewPanned: ??????];
}
- (void)onCViewPanned:(UIPanGestureRecognizer*)gesture {
// do something
}
答案 0 :(得分:2)
您可以像这样创建自定义UIPanGestureRecognizer
// MYPanGestureRecognizer.h
@interface MYPanGestureRecognizer : UIPanGestureRecognizer
@property (nonatomic, strong) NSString *data;
@end
// MYPanGestureRecognizer.m
@implementation MYPanGestureRecognizer
@end
// =================
...
MYPanGestureRecognizer *panObj = [[MYPanGestureRecognizer alloc] initWithTarget:self action:@selector(panDetected:)];
panObj.datas = @"Hello";
// ====================
-(void)panDetected:(UIPanGestureRecognizer *)panRecognizer {
MYPanGestureRecognizer *pan = (MYPanGestureRecognizer *)panRecognizer;
NSLog(@"data : %@", pan.data);
}
希望它能帮到你......