![](/img/trans.png)
[英]longpress gesture recognizer doesn't work on user location (MKuserlocation) on map view - iOS
[英]LongPress gesture doesn't work on iOS 5 and iOS 5.1 (but works on iOS 6)
以下代码不适用于iOS 5和iOS 5.1(但适用于iOS 6):
- (void)viewDidLoad {
...
UILongPressGestureRecognizer* gesture = [[[UILongPressGestureRecognizer alloc] initWithTarget:self action:@selector(handleLongPress:)] autorelease];
[myWebView addGestureRecognizer:gesture];
}
- (void)handleLongPress:(UIGestureRecognizer*)gestureRecognizer {
...
}
如何解决这个问题? 非常感谢您的帮助!
正确的代码:
- (void)viewDidLoad {
UILongPressGestureRecognizer* gesture = [[[UILongPressGestureRecognizer alloc] initWithTarget:self action:@selector(handleLongPress:)] autorelease];
gesture.delegate = self;
[myWebView addGestureRecognizer:gesture];
}
- (BOOL)gestureRecognizer:(UIGestureRecognizer *)gestureRecognizer shouldRecognizeSimultaneouslyWithGestureRecognizer:(UIGestureRecognizer *)otherGestureRecognizer {
return YES;
}
试试这个代码..
UILongPressGestureRecognizer *longpressGesture = [[UILongPressGestureRecognizer alloc] initWithTarget:self action:@selector(longPressHandler:)];
longpressGesture.minimumPressDuration = 5;
[longpressGesture setDelegate:self];
[myWebView addGestureRecognizer:longpressGesture];
[longpressGesture release];
- (void)longPressHandler:(UILongPressGestureRecognizer *)gestureRecognizer {
NSLog(@"longPressHandler");
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.