我正在尝试为iPhone Mapkit应用程序创建MKAnnotationView的子类,但由于某种原因,我突然遇到此错误:
Command /Developer/Platforms/iPhoneOS.platform/Developer/usr/bin/gcc-4.2 failed with exit code 1
这些是我的代码的头文件和主文件,似乎导致了错误。虽然错误没有明确地显示在此文件中,但如果我将.mmplementation中的.m文件注释到@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
创建的代码,子类已更改。
我在Snow Leopard上运行Xcode版本3.2.1。
答案 0 :(得分:0)
您是否将您的应用程序与MapKit.framework链接?编译器可能不知道MKAnnotationView cs因此输出此错误。
要将框架添加到项目中,请转到Xcode的其中一个菜单中的目标设置(不幸的是,我手边没有Xcode),在第一个选项卡上单击加号按钮并从中选择MapKit.framework列表。
我希望这会有所帮助。