我想将UIPanGestureRecognizer
参数从onCViewPanned
方法传递给showFollowing
。
我试图通过UIGestureRecognizerStateBegan
,但没有通过。我该如何解决?
-(void) showFollowing{
[self onCViewPanned: ??????];
}
- (void)onCViewPanned:(UIPanGestureRecognizer*)gesture {
// do something
}
最佳答案
您可以像这样创建自定义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);
}
希望对您有帮助...
关于ios - 将参数传递给方法-UIPanGestureRecognizer,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/29739437/