我开始在目标C中开发自己的导航地图,但最近在MapKit中遇到了死胡同。
我有XCode 4.5,iOS目标设置为6.0。和MapKit框架通过Link Binary With Libraries加载。
错误看起来像这样:
dyld: lazy symbol binding failed: Symbol not found: \314CGRectIsEmpty
Referenced from: /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator6.0.sdk/System/Library/Frameworks/MapKit.framework/MapKit
Expected in: /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator6.0.sdk/System/Library/Frameworks/CoreGraphics.framework/CoreGraphics
dyld: Symbol not found: \314CGRectIsEmpty
Referenced from: /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator6.0.sdk/System/Library/Frameworks/MapKit.framework/MapKit
Expected in: /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator6.0.sdk/System/Library/Frameworks/CoreGraphics.framework/CoreGraphics
当我开始时,它工作正常,但随后我添加了工具栏项和currentLocation按钮等功能,并且这个疯狂错误开始出现。首先我认为我的代码有问题。但后来我的程序运行了,并添加了功能,它开始抛出这个错误,当我把它放回去时,错误仍然存在。这是MapViewController的代码。
- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
{
self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
if (self) {
// Custom initialization
}
return self;
}
- (void)viewDidLoad
{
}
- (void)viewWillAppear:(BOOL)animated {
// 1
CLLocationCoordinate2D zoomLocation;
zoomLocation.latitude = 50.07499;
zoomLocation.longitude= 14.43976;
// 2
MKCoordinateRegion viewRegion = MKCoordinateRegionMakeWithDistance(zoomLocation, 10000, 10000);
// 3
MKCoordinateRegion adjustedRegion = [self.mapView regionThatFits:viewRegion];
// 4
[self.mapView setRegion:adjustedRegion animated:YES];
if (self.mapView.userLocationVisible){
self.currentLocationButton.enabled = YES;
}else{
self.currentLocationButton.enabled = NO;
timer = [NSTimer scheduledTimerWithTimeInterval:5.00 target:self selector:@selector(checkGeolocationAvailible) userInfo:nil repeats:YES];
[timer fire];
}
}
- (IBAction)checkGeolocationAvailible {
if (self.mapView.userLocationVisible){
self.currentLocationButton.enabled = YES;
[timer invalidate];
}
}
- (IBAction)showCurrentLocation {
if (self.mapView.userLocationVisible){
[self.mapView setCenterCoordinate:self.mapView.userLocation.coordinate];
}
}
- (void)didReceiveMemoryWarning
{
[super didReceiveMemoryWarning];
// Dispose of any resources that can be recreated.
}