我有 11 个 UIView,每个都设置了一个手势识别器。这个 UIView 在可变数组中,每个都有一个标签。如何将按下的 UIView 标记传递给方法选择器?
viewIcone.userInteractionEnabled = YES;
viewIcone.tag = index;
UITapGestureRecognizer * tap = [[UITapGestureRecognizer alloc]initWithTarget:self action:@selector(touchUp:)];
tap.delegate = self;
[viewIcone addGestureRecognizer:tap];
[self.arrayMutabile insertObject:viewIcone atIndex:index];
[self addSubview:viewIcone];
方法选择器的实现是:
-(void) touchUp: (UITapGestureRecognizer *) gestureRecognizer{
NSInteger tag = [self.arrayMutabile indexOfObject:self.viewIcone];
NSLog(@"the tag is %d", tag);
}
我总是离开10。哪里错了?提前致谢