0
我正在添加多個標籤與平底鍋手勢和點擊每個標籤上的手勢。但是當我點擊任何標籤時,平底鍋手勢不是從其他標籤刪除?如何從標籤中刪除平底鍋手勢後,點擊標籤
- (void)oneTap:(UITapGestureRecognizer *)gesture {
tapedLabel=gesture.view.tag;
//NSLog(@" tapped label is %d",numberOfLabel);
//add pangesture
self.pangesture = [[UIPanGestureRecognizer alloc] initWithTarget:self action:@selector(move:)] ;
[self.pangesture setMinimumNumberOfTouches:1];
[self.pangesture setMaximumNumberOfTouches:1];
[ self.pangesture setDelegate:self];
for(int i=1;i<=numberOfLabel;i++)
{
UILabel *label=[self.labelDict objectForKey:[NSString stringWithFormat:@"%d",i]];
label.userInteractionEnabled=YES;
if(i==tapedLabel)
{
//NSLog(@"i value %i tag value %d",i,tapedLabel);
[label addGestureRecognizer:self.pangesture];
// NSLog(@"remove gesture over label %@",label);
}
else
{
//NSLog(@"i value %i tag value %d",i,tapedLabel);
[label removeGestureRecognizer:self.pangesture];
NSLog(@"add gesture over label %@",label);
}
}
}
你能解釋一下你想達到什麼目的嗎? –