gpt4 book ai didi

ios - 将参数传递给方法 - UIPanGestureRecognizer

转载 作者:行者123 更新时间:2023-11-28 21:46:58 24 4
gpt4 key购买 nike

我想通过 showFollowing 方法将 UIPanGestureRecognizer 参数传递给 onCViewPanned

我试图传递 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/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com