按钮上的手势识别器

| 我想为按钮实现手势识别器(滑动动作)。问题是,按钮是通过编程方式创建的,根据某些条件是否存在。因此,我不知道是否有按钮或有多少个按钮。 我知道我需要类似的东西:
- (BOOL)gestureRecognizer:(UIGestureRecognizer *)gestureRecognizer shouldReceiveTouch:(UITouch *)touch {
    if (touch.view == aButtonView) {
        //get the button\'s tag
    }
}
当然,当按下任何按钮视图时,if语句应返回“是”。 有人对“ 1”一词应该有什么想法吗?还是有可能?提前致谢。     
已邀请:
您应该考虑使用
UISwipeGestureRecognizer
实例。将手势识别器附加到按钮对象-
UISwipeGestureRecognizer *swipe = [[UISwipeGestureRecognizer alloc] initWithTarget:self
                                                                            action:@selector(handleSwipe:)];
swipe.direction = UISwipeGestureRecognizerDirectionUp;
[button addGestureRecognizer:swipe];
[swipe release];
handleSwipe:
- (void) handleSwipe:(UISwipeGestureRecognizer *)swipe {
    NSInteger tag = swipe.view.tag;
}
应该是ѭ6     

要回复问题请先登录注册