0

クラス-(MyAnnotationアノテーション)のインスタンス0x11d0ce4b0は、キー値オブザーバーがまだ登録されている間に割り当てが解除されました。観測情報が漏洩し、他の物体に誤って付着する可能性もあります。NSKVODeallocateBreakにブレークポイントを設定して、デバッガーでここで停止します。現在の観測情報は次のとおりです。

しかし、deallocメソッドにブレークポイントを設定し、そこで、それらの通知の登録を解除します。Deallocが呼び出され、それが同じオブジェクトであり、登録解除のすべての呼び出しがそこにあることを確認しました。ですから、どうしてオブザーバーを排除できなかったのかわかりません。

4

1 に答える 1

1

カスタムを作成AnnotationView

#import <MapKit/MapKit.h>

@interface AnnotationView : MKPlacemark

@property (nonatomic, readwrite, assign) CLLocationCoordinate2D coordinate;

@property (nonatomic, strong) NSString *title;
@property (nonatomic, strong) NSString *subtitle;


@end

そしてで.m file

#import "AnnotationView.h"

@implementation AnnotationView

- (id)initWithCoordinate:(CLLocationCoordinate2D)coordinate addressDictionary:(NSDictionary *)addressDictionary
{
    if ((self = [super initWithCoordinate:coordinate addressDictionary:addressDictionary]))
    {
        self.coordinate = coordinate;
    }
    return self;
}

@end

//関連するアノテーション追加を使用#import "AnnotationView.h"します.m file

CLLocationCoordinate2D pCoordinate ;
pCoordinate.latitude = LatValue;
pCoordinate.longitude = LanValue;

// Create Obj Of  AnnotationView class  

AnnotationView *annotation = [[AnnotationView alloc] initWithCoordinate:pCoordinate addressDictionary:nil] ;

    annotation.title = @"I m Here";
    annotation.subtitle = @"This is Sub Tiitle";

[self.mapView addAnnotation:annotation];

上記は作成方法の簡単な例ですAnnotationView

于 2013-03-06T07:23:44.683 に答える