マップ注釈がクリックされたときにアニメーション化するストーリーボードに作成したいくつかのラベルを含む UIView があります。アニメーションが少しずれていることを除いて、すべてがうまく機能しています。注釈を初めてクリックしたとき、フレームの位置はアニメーション化されません。しかし、注釈を選択解除してから再度選択すると、それ以降は正常にアニメーション化されます。背景色もアニメーション化しますが、最初の選択でうまく機能しているように見えるので、それが何であれ、おそらくロード時に適切に設定されていないため、フレームプロパティに特有のものですか? 繰り返しますが、ストーリーボードですべてを行ったので、何が欠けているのかわかりません。
ラベル/ビューのコード (すべてストーリーボードに組み込まれ、適切な IBOutlets への参照アウトレットを使用)。ファイル.h:
@property (weak, nonatomic) IBOutlet UIView *stationinfo;
@property (weak, nonatomic) IBOutlet UILabel *stationname;
@property (weak, nonatomic) IBOutlet UILabel *stationsong;
@property (weak, nonatomic) IBOutlet UILabel *stationartist;
ファイル.m:
@synthesize stationinfo;
@synthesize stationname;
@synthesize stationsong;
@synthesize stationartist;
以下のコールバックのコードを見つけてください。
- (void) mapView:(MKMapView *)mapView didSelectAnnotationView:(MKAnnotationView *)view {
//NSLog(@"Selected ");
self.stationname.text = ((userStation *)view.annotation).name;
self.stationsong.text = ((userStation *)view.annotation).song;
self.stationartist.text = ((userStation *)view.annotation).artist;
[UIView
animateWithDuration:0.25
delay: 0.0
options: UIViewAnimationCurveEaseInOut
animations:^ {
CGRect anim = self.stationinfo.frame;
anim.origin.y = 0.0;
self.stationinfo.frame = anim;
self.stationinfo.backgroundColor = [UIColor redColor];
}
completion:^(BOOL finished){
NSLog(@"DONE!");
}];
}
- (void) mapView:(MKMapView *)mapView didDeselectAnnotationView:(MKAnnotationView *)view {
//NSLog(@"Deselected");
[UIView
animateWithDuration:0.25
delay: 0.0
options: UIViewAnimationCurveEaseInOut
animations:^ {
CGRect anim = self.stationinfo.frame;
anim.origin.y = -100.0;
self.stationinfo.frame = anim;
self.stationinfo.backgroundColor = [UIColor greenColor];
}
completion:^(BOOL finished){
NSLog(@"DONE!");
}];
}
あなたの助けに感謝します。ありがとうございました。