您好,我想模拟长按按钮?我怎样才能做到这一点?我认为需要一个计时器。你能帮助我吗?我明白UILongPressGestureRecognizer
了,但我怎样才能使用这种类型?
这是代码,它不识别长按
UILongPressGestureRecognizer *longPress = [[UILongPressGestureRecognizer alloc] initWithTarget:self action:@selector(longPress:)];
[self.button addGestureRecognizer:longPress];
[longPress release];
- (void)longPress:(UILongPressGestureRecognizer*)gesture {
if ( gesture.state == UIGestureRecognizerStateEnded ) {
NSLog(@"Long Press");
}
}