2

我按照Google Maps SDK for iOS - Getting started链接中提到的步骤进行操作。以下是我创建的文件

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.

视图控制器.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

主文件

#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.
    }
}

以下是错误的详细信息

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
4

1 回答 1

2

你的错误是:

'+[GMSCameraPosition cameraWithLatitude:longitude:zoom:]: 无法识别的选择器发送到类 0x25ad5c'

根据似乎已定义的 SDK。那是怎么定义的?如果它是一个类别,您可能需要使用标志 -ObjC 和 -all_load 链接 SDK。

于 2013-04-23T12:07:53.567 回答