我已经做到了,UILongPressGestureRecognizer 会丢下一个图钉,但我希望它是动画的。所以我尝试在 press: 方法中设置 animatesDrop 属性,我没有收到任何错误,但它不起作用。我不知道我是否将属性设置在错误的位置,或者什么。
这是代码。
-(void)viewDidLoad
{
UILongPressGestureRecognizer *longPress = [[UILongPressGestureRecognizer alloc]initWithTarget:self
action:@selector(press:)];
longPress.minimumPressDuration = 0.5f; //user needs to press for 2 seconds
[longPress setDelegate:self];
[worldView addGestureRecognizer:longPress];
[worldView setShowsUserLocation:YES];
}
-(void)press:(UILongPressGestureRecognizer *)recognizer
{
CGPoint touchPoint = [recognizer locationInView:worldView];
CLLocationCoordinate2D touchMapCoordinate = [worldView convertPoint:touchPoint toCoordinateFromView:worldView];
if (UIGestureRecognizerStateBegan == recognizer.state) {
BNRMapPoint *mp = [[BNRMapPoint alloc]initWithCoordinate:touchMapCoordinate
title:@"Some Title"];
[worldView addAnnotation:mp];
[mp setAnimatesDrop:YES];
}
}
任何帮助,将不胜感激。