最近下載的「MapKitDragAndDrop 3」包(http://github.com/digdog/MapKitDragAndDrop)在我的應用程序中使用。演示項目運行順利。Iphone Drag'n'Drop MapKit生成「無法識別的選擇器發送到實例」異常
DDAnnotation.h + m和DDAnnotationView.h + m文件都照原樣導入。調用該類的方法也被複制/粘貼。
DDAnnotation *annotation = [[[DDAnnotation alloc] initWithCoordinate:theCoordinate addressDictionary:nil] autorelease];
annotation.title = @"Drag to Move Pin";
annotation.subtitle = [NSString stringWithFormat:@"%f %f", annotation.coordinate.latitude, annotation.coordinate.longitude];
[self.mapView addAnnotation:annotation];
第一次運行導致「無法識別的選擇器發送到實例」異常。調試器建議我在DDAnnotation類中實現setCoordinate方法;但演示文件既沒有@synthesize也沒有方法實現。
DDAnnotation.m:
#import "DDAnnotation.h"
@implementation DDAnnotation
- (id)initWithCoordinate:(CLLocationCoordinate2D)coordinate addressDictionary:(NSDictionary *)addressDictionary {
if ((self = [super initWithCoordinate:coordinate addressDictionary:addressDictionary])) {
// NOTE: self.coordinate is now different from super.coordinate, since we re-declare this property in header,
// self.coordinate and super.coordinate don't share same ivar anymore.
self.coordinate = coordinate; // CHECKPOINT
}
return self;
}
@end
在跟蹤它的調試器落入DDAnnotation.h檢查點的DDAnnotation.m。在我的應用程序中,它沒有。
我真的期待錯誤是愚蠢的,但我不知道在哪裏看。謝謝。
我有一種感覺,當你設置字幕時,錯誤出現在行中。 這是當您嘗試訪問註釋的座標變量時。 – tadejsv 2010-07-20 17:25:20
DNK,請再次獲取該項目,我已經修復了導致問題(您有)的一些項目設置錯誤。 – digdog 2010-07-22 05:43:10