4

MKMapView に問題があります。次のような注釈を追加します。

// set up new points
for(int i = 0; i < [_locations count]; i++) {
    PPlace * place = [_locations objectAtIndex:i];
    PlaceAnnotation * placeAnnotation = [[PlaceAnnotation alloc] initWithPlace:place];
    // if annotation is for currently selected place
    placeAnnotation.isCurrent = i == currentIndexPath.row;
    [self.mapView addAnnotation:placeAnnotation];
    if (placeAnnotation.isCurrent) {
        [self.mapView selectAnnotation:placeAnnotation animated:YES];
    }
    [placeAnnotation release];
}

そのため、注釈ピンがタップされた後ではなく、追加された直後に吹き出しブーブルを表示しようとします。iOS 4.3.2 を搭載した iPhone 3GS でも、シミュレーターではすべて正常に動作します。ただし、吹き出しは iOS 4.1 を搭載した iPhone 4 では表示されません (ピンがタップされた後にのみ表示されます)。これを解決する方法はありますか?

4

4 に答える 4

1

私の推測では、アノテーション クラスの title プロパティに値を割り当てていないということです。に設定canShowCalloutしてもYES、タイトルに何かが含まれていない限り吹き出しは表示されません。

于 2011-06-25T16:55:01.670 に答える
0

追加してみてください

placeAnnotation.canShowCallout = YES;

したがって、次のようになります。

// set up new points
for(int i = 0; i < [_locations count]; i++) {
    PPlace * place = [_locations objectAtIndex:i];
    PlaceAnnotation * placeAnnotation = [[PlaceAnnotation alloc] initWithPlace:place];
    // if annotation is for currently selected place
    placeAnnotation.isCurrent = i == currentIndexPath.row;
    [self.mapView addAnnotation:placeAnnotation];
    if (placeAnnotation.isCurrent) {
        [self.mapView selectAnnotation:placeAnnotation animated:YES];
        placeAnnotation.canShowCallout = YES;
    }
    [placeAnnotation release];
}

お役に立てれば!ウェサム

于 2011-06-22T04:41:02.713 に答える
0

次のメソッドを実装する必要があります。

- (MKAnnotationView *)mapView:(MKMapView *)mapView viewForAnnotation:(id <MKAnnotation>)annotation

ここでドキュメントを見つけることができます

于 2012-07-04T07:58:07.767 に答える
0

あなたは間違った時間にそれを呼んでいます。ロードされるまで選択できません。

MKMapView のデリゲート メソッドを使用します。

- (void)mapView:(MKMapView *)mapView didAddAnnotationViews:(NSArray *)views

そして、そのメソッド呼び出しの内部から:

[yourMapView selectAnnotation: yourAnnotation animated: YES];
于 2012-07-16T22:02:00.957 に答える