Objective c MKAnnotationMethod AnimateDrop不工作
我已经做了,以便UILongPressGestureRecognitor掉一个pin,但我希望它是动画。因此,我尝试在press:方法中设置animatesDrop属性,我没有得到任何错误,但它不起作用。我不知道我是不是把房子放错地方了,还是怎么了 这是代码Objective c MKAnnotationMethod AnimateDrop不工作,objective-c,mkannotation,Objective C,Mkannotation,我已经做了,以便UILongPressGestureRecognitor掉一个pin,但我希望它是动画。因此,我尝试在press:方法中设置animatesDrop属性,我没有得到任何错误,但它不起作用。我不知道我是不是把房子放错地方了,还是怎么了 这是代码 -(void)viewDidLoad { UILongPressGestureRecognizer *longPress = [[UILongPressGestureRecognizer alloc]initWithTarget:s
-(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];
}
}
任何帮助都将不胜感激。是MKPinAnnotationView的一种方法,而您的BNRMapPoint
似乎是实现MKAnnotation
协议的注释类
您需要提供mapView:viewForAnnotation:
方法来返回注释的MKPinAnnotationView,您可以在其中将MKPinAnnotationView的animatesDrop
属性设置为YES
您可以参考Apple的示例代码。我尝试实现mapView:viewForAnnotation方法,但它用pin替换了currentLocation。如何保持当前位置而不在当前位置上放置pin?我尝试将BNRMapPoint更改为MKPinAnnotationView的子类,并将animatesDrop属性设置为“是”。但它仍然不起作用。
-(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];
}