ios - 使用 map 上的 PINS 时,由于未捕获的异常 'NSInvalidArgumentException' 而终止应用程序

标签 ios mapkit xcode4.2

当我运行我的应用程序时,它崩溃了并且出现了这个错误:

Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[AnnotationsDisplay coordinate]: unrecognized selector sent to instance 0x795bda0'

AnnotationsDisplay 这是一个管理在 map 上显示 PINS 的类。

编辑: 这是我的 AnnotationsDisplay 类代码:

#import <Foundation/Foundation.h>
#import <MapKit/MapKit.h>
@interface AnnotationsDisplay : NSObject<MKAnnotation> {
    NSString *title;
    CLLocationCoordinate2D coordinate;
}
- (id)initWithTitle:(NSString *)ttl andCoordinate:(CLLocationCoordinate2D)c2d;
@end

.m:

#import "AnnotationsDisplay.h"

@implementation AnnotationsDisplay
- (id)initWithTitle:(NSString *)ttl andCoordinate:(CLLocationCoordinate2D)c2d {
    title = ttl;
    coordinate = c2d;
    return self;
}
@end

最佳答案

@protocol MKAnnotation <NSObject>

// Center latitude and longitude of the annotion view.
// The implementation of this property must be KVO compliant.
@property (nonatomic, readonly) CLLocationCoordinate2D coordinate;

@optional

// Title and subtitle for use by selection UI.
@property (nonatomic, readonly, copy) NSString *title;
@property (nonatomic, readonly, copy) NSString *subtitle;

// Called as a result of dragging an annotation view.
- (void)setCoordinate:(CLLocationCoordinate2D)newCoordinate NS_AVAILABLE(NA, 4_0);

@end

属性已经在 MKAnnotation 协议(protocol)中声明。只需为每个属性添加 @synthesize。

关于ios - 使用 map 上的 PINS 时,由于未捕获的异常 'NSInvalidArgumentException' 而终止应用程序,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8616672/

相关文章:

ios - UIScrollView 暂停 NSTimer 直到滚动完成

ios - 使用经度和纬度获取位置 iOS 6 的方向

xcode4.2 - Xcode 4.2 中的 Bootstrap 错误 iOS 5.0 模拟器

iphone - 将 FreeTDS 交叉编译到 iPhone

ios - AVAssetWriter 为影片输出添加绿框

ios - 检测网页请求是否来自浏览器与 UIWebView

ios - 分享 mkmapview 截图

ios - CoreData MapKit swift 3

ios - 如何在 iOS 中搜索姓名列表?

ios - 应用程序在按钮上崩溃 Click Action iOS