我有一个UILongPressGestureRecognizer添加到UIButton。当按下UIButton时,按预期突出显示。但是,当UILongPressGestureRecognizer选择器被调用时,突出显示被关闭。UILongPressGestureRecognizer关闭UIButton突出显示
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秒后被调用。该按钮在选择器被调用之前突出显示,但在选择器被调用时不会突出显示,即使我仍在按下按钮。
任何人都可以解释为什么发生这种情况,以及如何防止它?我希望按钮在按下时始终保持突出显示。谢谢。
但它会调用touchUpInside的选择器。如何防止? – user1010819 2013-11-21 19:35:21