这是关于使用MKMapKit的iPhone App:
我为可拖动的注释创建了一个自定义MKAnnotationView.我想创建一个自定义动画.我设置了一个自定义图钉图像,注释是可拖动的(这里没有显示,它发生在mapview中),代码如下:
- (void) movePinUpFinished {
[super setDragState:MKAnnotationViewDragStateDragging];
[self setDragState:MKAnnotationViewDragStateDragging];
}
- (void) setDragState:(MKAnnotationViewDragState) myState {
if (myState == MKAnnotationViewDragStateStarting) {
NSLog(@"starting");
CGPoint endPoint = CGPointMake(self.center.x,self.center.y-20);
self.center = endPoint;
[self movePinUpFinished];
}
if (myState == MKAnnotationViewDragStateEnding) {
NSLog(@"ending");
[super setDragState:MKAnnotationViewDragStateEnding];
[self setDragState:MKAnnotationViewDragStateNone];
[super setDragState:MKAnnotationViewDragStateNone];
}
if (myState == MKAnnotationViewDragStateDragging) {
NSLog(@"dragging");
}
if (myState == MKAnnotationViewDragStateCanceling) {
NSLog(@"cancel");
}
if (myState == MKAnnotationViewDragStateNone) {
NSLog(@"none");
}
}
Run Code Online (Sandbox Code Playgroud)
一切正常,注释向上移动一点,可拖动,当我发布注释时,mapview会收到"dragstateending".
但现在我希望动画在一段时间内运行并将dragStateStarting更改为以下内容:
if (myState == MKAnnotationViewDragStateStarting) {
NSLog(@"starting");
CGPoint endPoint = CGPointMake(self.center.x,self.center.y-20); …Run Code Online (Sandbox Code Playgroud)