本文介绍了将NSDictionary作为参数传递给UITapGestureRecognizer的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我想将 NSArray 作为参数传递给 UITapGestureRecognizer ,并在downloadOptionPressed方法中访问它。我该怎么做?
I want to pass a NSArray as a parameter to UITapGestureRecognizer and access it in downloadOptionPressed method. How can I do this ?
NSArray
NSArray *parameters = [NSArray arrayWithObjects:currentTrack, nil];创建 UITapGestureRecognizer
UITapGestureRecognizer *downloadOptionPressed = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(timeFrameLabelTapped:)]; [downloadOption addGestureRecognizer:downloadOptionPressed];downloadOptionPressed 方法
-(void)downloadOptionPressed:(UIGestureRecognizer*)recognizer{ }推荐答案
您是否有理由不能将信息存储在拥有的视图控制器中?是抽象吗?
Is there a reason you can't store the information in the owning view controller? Is it for abstraction?
您可以随时扩展UITapGestureRecognizer以携带更多数据:
You can always extend UITapGestureRecognizer to carry more data:
@interface UserDataTapGestureRecognizer : UITapGestureRecognizer @property (nonatomic, strong) id userData; @end @implementation UserDataTapGestureRecognizer @end...
UserDataTapGestureRecognizer *downloadOptionPressed = [[UserDataTapGestureRecognizer alloc] initWithTarget:self action:@selector(timeFrameLabelTapped:)]; downloadOptionPressed.userData = parameters;...
- (void)downloadOptionPressed:(UserDataTapGestureRecognizer *)recognizer { NSArray *parameters = recognizer.userData; }更多推荐
将NSDictionary作为参数传递给UITapGestureRecognizer
发布评论