【发布时间】:2011-02-15 20:28:24
【问题描述】:
我有一个 UILongPressGestureRecognizer 添加到 UIButton。当我按下 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 秒后被调用。该按钮在调用选择器之前突出显示,但在调用选择器时未突出显示,即使我仍在按下按钮。
谁能解释为什么会发生这种情况,以及如何预防?我希望按钮在按下时始终保持突出显示。谢谢。
【问题讨论】: