首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >MKMapKit和IOS4

MKMapKit和IOS4
EN

Stack Overflow用户
提问于 2010-11-13 03:32:43
回答 2查看 2.9K关注 0票数 5

大家好,我正在尝试让MKMapView启动并运行,但是我似乎不能通过一个似乎是引用错误的问题。我花了几个小时在谷歌上搜索,就像昨晚一样。

标题:

代码语言:javascript
复制
#import <UIKit/UIKit.h>
#import <MapKit/MapKit.h>

@interface MapsViewController : UIViewController {
    MKMapView *mapView;
}

@end

Main:

代码语言:javascript
复制
#import "MapsViewController.h"

@implementation MapsViewController
- (void)viewDidLoad {
    [super viewDidLoad];
    mapView = [[MKMapView alloc] initWithFrame:self.view.frame];
    [self.view insertSubview:mapView atIndex:0];
}

- (void)didReceiveMemoryWarning {
    // Releases the view if it doesn't have a superview.
    [super didReceiveMemoryWarning];

    // Release any cached data, images, etc that aren't in use.
}

- (void)viewDidUnload {
    // Release any retained subviews of the main view.
    // e.g. self.myOutlet = nil;
}
- (void)dealloc {
    [super dealloc];
    [mapView dealloc];
}

@end

错误:

代码语言:javascript
复制
Build Maps of project Maps with configuration Debug

Ld build/Debug-iphonesimulator/Maps.app/Maps normal i386
cd /workspace/iphone_dev/Maps
setenv MACOSX_DEPLOYMENT_TARGET 10.6
setenv PATH "/Developer/Platforms/iPhoneSimulator.platform/Developer/usr/bin:/Developer/usr/bin:/usr/bin:/bin:/usr/sbin:/sbin"
/Developer/Platforms/iPhoneSimulator.platform/Developer/usr/bin/gcc-4.2 -arch i386 -isysroot /Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator4.1.sdk -L/workspace/iphone_dev/Maps/build/Debug-iphonesimulator -F/workspace/iphone_dev/Maps/build/Debug-iphonesimulator -filelist /workspace/iphone_dev/Maps/build/Maps.build/Debug-iphonesimulator/Maps.build/Objects-normal/i386/Maps.LinkFileList -mmacosx-version-min=10.6 -Xlinker -objc_abi_version -Xlinker 2 -framework Foundation -framework UIKit -framework CoreGraphics -o /workspace/iphone_dev/Maps/build/Debug-iphonesimulator/Maps.app/Maps

Undefined symbols:
  "_OBJC_CLASS_$_MKMapView", referenced from:
      objc-class-ref-to-MKMapView in MapsViewController.o
ld: symbol(s) not found
collect2: ld returned 1 exit status

我设法在适当的文件夹中找到了MKMapKit.framework。他们是不是我漏掉了什么?

EN

回答 2

Stack Overflow用户

回答已采纳

发布于 2010-11-13 03:45:02

听起来您需要通过右键单击Xcode中的项目列表并选择Add->Existing MapKit.framework来将框架添加到项目中。选择MapKit,您应该会看到它列在Targets -> Your App -> Link Binary with Libraries下面。

票数 10
EN

Stack Overflow用户

发布于 2010-11-13 03:53:56

博斯马克说的是对的。还要注意,您的dealloc方法是不正确的。

代码语言:javascript
复制
- (void)dealloc {
  [mapView release];
  [super dealloc];
}

你不应该对任何东西调用dealloc,除了super和super;总是在你的dealloc方法的末尾。

票数 3
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/4168354

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档