谷歌地图SDK与ios6集成
问题描述:
我创建了API密钥,并尝试在谷歌和谷歌地图提供的演示项目工作正常。然而,试图创建一个示例项目,并在运行时集成谷歌地图sdk崩溃。谷歌地图SDK与ios6集成
步骤其次
创建与禁止的使用的故事板和ARC上的单一视图的应用程序。 使用我的项目的包标识符创建了一个API密钥,它是rosnMapTest 将GoogleMapsframework包复制到Framework组中。 复制GoogleMapsbundle从资源文件夹到框架组 添加了所有如下框架
<pre>
<code>
AVFoundation.framework
CoreData.framework
CoreLocation.framework
CoreText.framework
GLKit.framework
ImageIO.framework
libicucore.dylib
libstdc++.dylib
libz.dylib
OpenGLES.framework
QuartzCore.framework
SystemConfiguration.framework
</code>
</pre>
Fixed the default Architectures and Other Linker Flags
Imported GoogleMaps.h and added google API key in AppDelegate
<pre>
<code>
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
// Override point for customization after application launch.
self.viewController = [[TestViewController alloc] initWithNibName:@"TestViewController" bundle:nil];
self.window.rootViewController = self.viewController;
[self.window makeKeyAndVisible];
[GMSServices provideAPIKey:@"AIzaSyAVEDscm0b307ZDFpOnn4zr4saLJF43E0Y"];
return YES;
}
</code>
</pre>
Added following code in viewcontroller
<pre>
<code>
#import "TestViewController.h"
#import <GoogleMaps/GoogleMaps.h>
@interface TestViewController()
@end
@implementation TestViewController
GMSMapView *mapView_;
- (void) viewDidLoad
{
[super viewDidLoad];
}
- (void)loadView {
GMSCameraPosition *camera = [GMSCameraPosition cameraWithLatitude:-33.8683
longitude:151.2086
zoom:6];
mapView_ = [GMSMapView mapWithFrame:CGRectZero camera:camera];
mapView_.myLocationEnabled = YES;
self.view = mapView_;
GMSMarkerOptions *options = [[GMSMarkerOptions alloc] init];
options.position = CLLocationCoordinate2DMake(-33.8683, 151.2086);
options.title = @"Sydney";
options.snippet = @"Australia";
[mapView_ addMarkerWithOptions:options];
}
@end
</code>
</pre>
<pre>
<code>
Error in RUNTIME: “2013-02-23 19:37:27.697 MapTest[2947:c07] +[GMSCameraPosition cameraWithLatitude:longitude:zoom:]: unrecognized selector sent to class 0xf2a4
(lldb)”
</code>
</pre>
答
我想到的。你不是在步骤 设置7
https://developers.google.com/maps/documentation/ios/start#add_a_map
“选择你的项目,而不是一个具体的目标,并打开Build设置标签。 与ARMv7的替换架构的默认值。在其它链接器标记部分,请添加-ObjC。如果这些设置不可见,请将“生成设置”栏中的过滤器从“基本”更改为“全部”。
答
我有同样的问题。确保将-ObjC标志添加到“Target”的“Build Settings”中,而不是“Project”。
P.S.在两个地方添加它也不会破坏它。
答
你可以使用故事板。这让iOS的生活更轻松,我认为:)
你有一个工作example here
还有连接到谷歌地图控制器OpenGL的控制器。如果你不希望它可以通过在ViewController.m删除以下代码忽略它:
UIStoryboard *mainStoryboard = [UIStoryboard storyboardWithName:@"MainStoryboard_iPhone" bundle:nil];
_openGLController = (OpenGLController *)[mainStoryboard instantiateViewControllerWithIdentifier:@"openGLController"];
[self addChildViewController:_openGLController];
[self.view addSubview:_openGLController.view];
[self didMoveToParentViewController:self];
有了这一个我可以帮你,如果你遇到的问题。