我在UIButton上添加了一个UILongPressGestureRecognizer。当我按下UIButton时,它会像预期的那样被高亮显示。然而,当UILongPressGestureRecognizer的选择器被调用时,高亮显示就被关闭了。
UILongPressGestureRecognizer *longpressGesture =
[[UILongPressGestureRecognizer alloc] initWithTarget:self
action:@selector(longPressHandler:)];
longpressGesture.minimumPressDuration = 5;
[longpressGesture setDelegate:self];
[self.myUIButton addGestureRecognizer:longpressGesture];
[longpressGesture release];
- (void)longPressHandler:(UILongPressGestureRecognizer *)gestureRecognizer {
NSLog(@"longPressHandler");
}
在上面的例子中,选择器在按住按钮5秒钟后被调用。在选择器被调用之前,按钮会被突出显示,但是当选择器被调用时,即使我仍然按住按钮,按钮也会取消突出显示。有人可以解释为什么会发生这种情况以及如何防止它发生吗?我希望按钮在按下时始终保持突出显示。谢谢。