0

我正在尝试为 iPhone Mapkit 应用程序创建 MKAnnotationView 的子类,但由于某种原因,我突然遇到了这个错误:

Command /Developer/Platforms/iPhoneOS.platform/Developer/usr/bin/gcc-4.2 failed with exit code 1

这些是我似乎导致错误的代码的头文件和主文件。尽管此文件没有特别显示该错误,但如果我将 .m 文件从 @implementation 注释到 @end,则不会出现该错误。但是,如果我评论实现中的所有内容(不包括 @implementation 本身),它仍然会出现。

PhotoAnnotationView.h

#import <UIKit/UIKit.h>
#import <MapKit/MapKit.h>

@interface PhotoAnnotationView : MKAnnotationView { 
    UIImageView *thumb; 
}

@property (nonatomic, retain) IBOutlet UIImageView *thumb;

@end

PhotoAnnotationView.m

#import "PhotoAnnotationView.h"


@implementation PhotoAnnotationView

@synthesize thumb;

- (id)initWithFrame:(CGRect)frame {
    if (self = [super initWithFrame:frame]) {
        // Initialization code
    }
    return self;
}


- (void)drawRect:(CGRect)rect {
    // Drawing code
}


- (void)dealloc {
    [super dealloc];
}


@end

这基本上与 Xcode 通过New File... > Objective-C Class > Subclass of: UIView更改子类创建的代码相同。

我在运行 Xcode 3.2.1 版的 Snow Leopard 上。

4

1 回答 1

0

您是否将您的应用程序与 MapKit.framework 链接?编译器可能不知道 MKAnnotationView cs,因此会输出此错误。

要将框架添加到您的项目中,请转到 Xcode 的一个菜单中的 Target settings(不幸的是,我手头没有 Xcode),然后在第一个选项卡上单击加号按钮并从列表中选择 MapKit.framework。

我希望这会有所帮助。

于 2009-11-19T22:20:31.517 回答