nik*_*ale 1 iphone objective-c uigesturerecognizer ios
我在滚动视图中创建动态标签,我想为所有这些动态生成的标签添加单个手势识别器.我正在创建如下手势
UIPanGestureRecognizer *gesture = [[UIPanGestureRecognizer alloc]
initWithTarget:self
action:@selector(handlePan:)] ;
Run Code Online (Sandbox Code Playgroud)
现在我想将此手势添加到多个标签.是否可以为动态创建的标签添加相同的手势?
试试这个..为我工作
NSMutableArray *arrayForLabels= [NSMutableArray array];
[arrayForLabels addObject:label];
[arrayForLabels addObject:label1];
// enable touch delivery
label.userInteractionEnabled = YES;
label1.userInteractionEnabled = YES;
for (UILabel *myLabel in arrayForLabels) {
UIPanGestureRecognizer *gesture = [[UIPanGestureRecognizer alloc]
initWithTarget:self
action:@selector(handlePan:)] ;
[myLabel addGestureRecognizer:gesture];
}
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
4173 次 |
| 最近记录: |