如何在按住地图时创建事件?
它在 Maps.app 中的工作方式相同:当您点击并按住一两秒时,应用程序会在此处放置一个图钉。
我将在此处附加一段代码(我需要 LongPress 来处理注释,但它在此代码中不起作用)。请考虑提供帮助。
MKPinAnnotationView* pinView = [[[MKPinAnnotationView alloc] initWithAnnotation:annotation reuseIdentifier:MeAnnotationIdentifier] autorelease];
pinView.canShowCallout = NO;
UILongPressGestureRecognizer *longPressGesture = [[UILongPressGestureRecognizer alloc] initWithTarget:self action:@selector(showCountdown:)];
[pinView addGestureRecognizer:longPressGesture];
[longPressGesture release];
It works the same way in Maps.app: when you tap and hold for a second or two the app drops a pin there.
I'll attach a piece of code here (I need LongPress to work on annotations and it doesn't work in this code). Please consider helping.
MKPinAnnotationView* pinView = [[[MKPinAnnotationView alloc] initWithAnnotation:annotation reuseIdentifier:MeAnnotationIdentifier] autorelease];
pinView.canShowCallout = NO;
UILongPressGestureRecognizer *longPressGesture = [[UILongPressGestureRecognizer alloc] initWithTarget:self action:@selector(showCountdown:)];
[pinView addGestureRecognizer:longPressGesture];
[longPressGesture release];
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您可以使用 UILongPressGestureRecognizer。您可以指定它触发所需的时间。然而,在那里放置一个图钉是正确放置图像并为其设置动画的问题,但是为您提供代码将为您完成几乎所有工作,而不是简单地帮助您解决问题?
You can use a UILongPressGestureRecognizer. You can specify the time needed for it to fire. Dropping a pin there however is a matter of properly placing and animating an image, but giving you code for that would be doing pretty much all work for you instead of simply helping you with your problem?