我有MKPointAnnotation
用以下方法,該方法我在iOS 4運行的子類:爲什麼UIView:animateWithDuration會立即完成?
- (void)animate {
[UIView
animateWithDuration: 3.0
delay:1.0
options:UIViewAnimationOptionAllowUserInteraction
animations:^{
CLLocationCoordinate2D loc =
CLLocationCoordinate2DMake([self coordinate].latitude + 0.001,
[self coordinate].longitude + 0.001);
[self setCoordinate:loc];
}
completion:^(BOOL finished) {
NSLog(@"Is completed");
}];
}
它通過點擊UIBarButtonItem
調用。
我希望看到我的註釋在MKMapView
之間移動。但是,所有我看到的是其最後的歸宿註釋當我打電話的方法是這樣的:
[mapView addAnnotation:myAnnotation];
[myAnnotation animate];
[myAnnotation release];
,如果我這樣調用此方法的預期動畫只發生:
[mapView addAnnotation:myAnnotation];
[myAnnotation performSelector:@selector(animate) withObject:nil afterDelay:0.5];
[myAnnotation release];
注意,我如果'afterDelay'小,例如,得到意想不到的行爲< 0.1s。
任何想法,爲什麼這可能是這種情況?
座標屬性是否自動生成動畫?我沒有使用過MapKit,但並不是所有的屬性都是自動動畫的。 – Joe 2011-05-03 13:15:11
我不認爲座標屬性本身是自動生成動畫的,但我相信'MKPointAnnotation'的實現必須連接到UIView的動畫屬性,因爲如果我使用'animate'方法'performSelector'具有足夠大的'afterDelay'值。 – Dan 2011-05-03 13:20:53
當我使用傳統的非塊動畫時,我遇到同樣的問題。我仍然沒有找到這個問題的答案。 – Dan 2011-06-27 06:38:13