iPhone 应用程序中的 uigesturerecognizer
您好,我想模拟长按按钮吗?我该怎么做?我认为需要一个计时器。你能帮助我吗?我看到 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");
}
}
Hello I want to emulate a long a press button? how can I do this? I think a timer is needed. Can you help me? I see UILongPressGestureRecognizer
but how can I utilize this type?
here is the code , it isn't recognize long press
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");
}
}
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
为了使用
UILongPressGestureRecognizer
,您必须设置minimumPressDuration
属性。这指定了手势识别器被触发之前等待的时间。例如In order to utilize
UILongPressGestureRecognizer
you must set theminimumPressDuration
property. This specifies how long to wait until your gesture recognizer is fired. For example