Ash*_*wal 4 objective-c nsarray ios uitapgesturerecognizer
我想将NSArray一个参数传递给UITapGestureRecognizerdownloadOptionPressed方法并在其中访问它.我怎样才能做到这一点 ?
该 NSArray
NSArray *parameters = [NSArray arrayWithObjects:currentTrack, nil];
Run Code Online (Sandbox Code Playgroud)
创造 UITapGestureRecognizer
UITapGestureRecognizer *downloadOptionPressed = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(timeFrameLabelTapped:)];
[downloadOption addGestureRecognizer:downloadOptionPressed];
Run Code Online (Sandbox Code Playgroud)
该downloadOptionPressed方法
-(void)downloadOptionPressed:(UIGestureRecognizer*)recognizer{
}
Run Code Online (Sandbox Code Playgroud)
Bri*_*kel 11
有没有理由不能将信息存储在拥有的视图控制器中?是抽象吗?
您始终可以扩展UITapGestureRecognizer以携带更多数据:
@interface UserDataTapGestureRecognizer : UITapGestureRecognizer
@property (nonatomic, strong) id userData;
@end
@implementation UserDataTapGestureRecognizer
@end
Run Code Online (Sandbox Code Playgroud)
...
UserDataTapGestureRecognizer *downloadOptionPressed =
[[UserDataTapGestureRecognizer alloc] initWithTarget:self
action:@selector(timeFrameLabelTapped:)];
downloadOptionPressed.userData = parameters;
Run Code Online (Sandbox Code Playgroud)
...
- (void)downloadOptionPressed:(UserDataTapGestureRecognizer *)recognizer {
NSArray *parameters = recognizer.userData;
}
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
2408 次 |
| 最近记录: |