2013-04-23 61 views
2

我遵循Google Maps SDK for iOS - Getting started鏈接中提到的步驟。 以下是我創建如何解決Xcode中使用Google Maps SDK for iOS時出現的「線程1:SIGABRT錯誤」錯誤

AppDelegate.m

#import "AppDelegate.h" 
#import "ViewController.h" 

@implementation AppDelegate 

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions 
{ 
    self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]]; 
    // Override point for customization after application launch. 
    self.viewController = [[ViewController alloc] initWithNibName:@"ViewController" bundle:nil]; 
    [GMSServices provideAPIKey:@"AIzaXXXXXXXXXXeGuCyxChdTECXXXXXXXXXXV9E"]; 
    self.window.rootViewController = self.viewController; 
    [self.window makeKeyAndVisible]; 

    return YES; 
} 
//Other functions are there as it is. 

ViewController.m

#import "ViewController.h" 
#import <GoogleMaps/GoogleMaps.h> 

@interface ViewController() 

@end 

@implementation ViewController 
{ 
    GMSMapView *mapView_; 
} 

- (void)viewDidLoad 
{ 
    [super viewDidLoad]; 
    // Do any additional setup after loading the view, typically from a nib. 
} 

- (void)didReceiveMemoryWarning 
{ 
    [super didReceiveMemoryWarning]; 
    // Dispose of any resources that can be recreated. 
} 

- (void)loadView 
{ 
    // Create a GMSCameraPosition that tells the map to display the 
    // coordinate -33.86,151.20 at zoom level 6. 
    GMSCameraPosition *camera = [GMSCameraPosition cameraWithLatitude:-33.86 
                 longitude:151.20 
                  zoom:6]; 
    mapView_ = [GMSMapView mapWithFrame:CGRectZero camera:camera]; 
    mapView_.myLocationEnabled = YES; 
    self.view = mapView_; 

    // Creates a marker in the center of the map. 
    GMSMarker *marker = [[GMSMarker alloc] init]; 
    marker.position = CLLocationCoordinate2DMake(-33.86, 151.20); 
    marker.title = @"Sydney"; 
    marker.snippet = @"Australia"; 
    marker.map = mapView_; 
} 

@end 

的main.m

#import <UIKit/UIKit.h> 

#import "AppDelegate.h" 

int main(int argc, char *argv[]) 
{ 
    @autoreleasepool 
    { 
     return UIApplicationMain(argc, argv, nil, NSStringFromClass([AppDelegate class])); 
     //Error is displayed in the above line. 
    } 
} 
012文件

以下是錯誤的詳細信息

2013-04-23 17:02:37.482 GMap[8146:12e03] +[GMSCameraPosition cameraWithLatitude:longitude:zoom:]: unrecognized selector sent to class 0x25ad5c 
2013-04-23 17:02:37.483 GMap[8146:12e03] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '+[GMSCameraPosition cameraWithLatitude:longitude:zoom:]: unrecognized selector sent to class 0x25ad5c' 
*** First throw call stack: 
(0x2418012 0x223de7e 0x24a32ad 0x2407bbc 0x240794e 0x2bb4 0x1262ff8 0x1263232 0x11b23d5 0x11b276f 0x11b2905 0x11bb917 0x27ad 0x117f157 0x117f747 0x118094b 0x1191cb5 0x1192beb 0x1184698 0x3133df9 0x3133ad0 0x238dbf5 0x238d962 0x23bebb6 0x23bdf44 0x23bde1b 0x118017a 0x1181ffc 0x24bd 0x23e5) 
libc++abi.dylib: terminate called throwing an exception 

回答

2

你的錯誤是:

'+ [GMSCameraPosition cameraWithLatitude:經度:縮放:]:無法識別的選擇發送到類0x25ad5c'

根據似乎定義的SDK。這是如何定義的?如果它是一個類別,則可能需要使用標誌-ObjC和-all_load與SDK進行鏈接。

+0

謝謝..我剛纔意識到我錯過了這一步。添加-ObjC與其他的不同,因爲其他步驟需要從下拉菜單中選擇選項,而這個需要我輸入它。 – Manas 2013-04-23 12:20:54

+0

我仍然可以在應用程序中看到一個針。我沒有看到地圖。我現在可能錯過了什麼。如何在模擬器中獲取地圖? – Manas 2013-04-23 12:22:27

+0

不知道,我從來沒有使用SDK。 – yaakov 2013-04-23 12:35:07

相關問題