iphone - 是什么在MKAnnotationView的子类中导致此错误?

标签 iphone xcode compiler-errors mapkit

我正在尝试为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/

相关文章:

c - 为什么我在 C 程序中收到杂散 '342' 错误?

iphone - 单击 DetailDisclosureButton 进行导航?

json - 我希望 Swift 程序中 "self.q"中的值也能打印到 xcode 控制台

xcode - 如何禁用 "Multiple methods named ... found with mismatched result, parameter type or attributes"

qt - Qt使用外部变量进行编译的问题

java - Try-With-Resources示例,编译失败。代码有什么问题

iphone - Cocoa 对象数组转字符串

ios - iOS 上的应用程序私有(private)目录,可以访问从 Qt API 创建文件

ios - 分发B2B应用

ios - iPhone 构建失败 - XCode 5.1.1 iOS 7