私は持っている
- ストーリーボードにあるマップ ビューのデリゲートであるMyMapViewControllerという名前のビュー コントローラー、
- MyMapViewControllerの子ビュー コントローラーであるMyListViewControllerという名前のビュー コントローラー (つまり、ストーリーボードのコンテナー ビュー ' myContainerView ') 。
したがって、ストーリーボードには次のものがあります: http://pasteboard.co/1YAmM2ZU.png
MyMapViewControllerでは、最初にmyContainerViewのフレームを次のように設定して、表示される唯一の部分がMyMapViewControllerの下部にあるナビゲーション バーになるようにします。
CGRect destFrame = self.myContainerView.frame;
CGFloat navBarHeight = 44;
destFrame.origin.y = self.view.frame.size.height - navBarHeight;//to bottom of the screen; navigation bar yields 44 points
[UIView animateWithDuration:0
animations:^{
self.myContainerView.frame = destFrame;
}
];
MyMapViewControllerでは、マップにいくつかの注釈を設定しました。デリゲート メソッドは次のとおりです。
- (MKAnnotationView *)mapView:(MKMapView *)mapView viewForAnnotation:(id <MKAnnotation>) annotation{
NSLog(@"welcome into the map view annotation");
// if it's the user location, just return nil.
if ([annotation isKindOfClass:[MKUserLocation class]])
return nil;
// try to dequeue an existing pin view first
static NSString* AnnotationIdentifier = @"AnnotationIdentifier";
MKPinAnnotationView* pinView = [[MKPinAnnotationView alloc]
initWithAnnotation:annotation reuseIdentifier:AnnotationIdentifier];
pinView.animatesDrop=YES;
pinView.canShowCallout=YES;
pinView.pinColor=MKPinAnnotationColorPurple;
UIButton* rightButton = [UIButton buttonWithType:UIButtonTypeDetailDisclosure];
[rightButton setTitle:annotation.title forState:UIControlStateNormal];
[rightButton addTarget:self
action:@selector(showDetails:)
forControlEvents:UIControlEventTouchUpInside];
pinView.rightCalloutAccessoryView = rightButton;
UIImageView *profileIconView = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"annotationProfile.png"]];
pinView.leftCalloutAccessoryView = profileIconView;
return pinView;
}
問題は、マップをユーザー自身の場所、またはマップに最初に表示されていない注釈の場所にスクロールしたり、注釈の 1 つをクリックしたりすると、myContainerViewが突然表示されることです。(ストーリーボードで設定した場所に戻ります。)ただし、myContainerViewは元の場所にとどめておいてください。
なぜそれが起こるのかいくつかの可能な説明を思いつきましたが、どうすればこの問題を克服できるのかよくわかりません. 助言がありますか?
前もって感謝します。