我正在尝试为iPhone Mapkit应用程序创建MKAnnotationView的子类,但是由于某种原因,我突然遇到此错误:Command /Developer/Platforms/iPhoneOS.platform/Developer/usr/bin/gcc-4.2 failed with exit code 1
这些是我的 header 和主文件,这些文件似乎是导致错误的代码。尽管此文件未特别显示该错误,但是如果我将.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
这基本上与更改了子类的
New File... > Objective-C Class > Subclass of: UIView
通过Xcode创建的代码相同。我正在运行Xcode 3.2.1版的Snow Leopard。
最佳答案
您是否将应用程序与MapKit.framework链接?编译器可能不知道MKAnnotationView cs,因此输出此错误。
要将框架添加到您的项目中,请在Xcode的菜单之一中的Target settings(不幸的是,我手头没有Xcode)并在第一个选项卡上单击加号按钮,然后从列表中选择MapKit.framework。
希望对您有所帮助。
关于iphone - 是什么在MKAnnotationView的子类中导致此错误?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/1766900/