Google Maps animateToCameraPosition iOS7问题 [英] Google Maps animateToCameraPosition iOS7 issue

查看:97
本文介绍了Google Maps animateToCameraPosition iOS7问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试将Google Maps API安装到适用于iOS7的应用中。在遵循Google的准则和视频之后,我得到了以下错误: [GMSMapView animateToCameraPosition:]:无法识别的选择器发送到实例0x10b98e6c0



我正在使用Storyboard,并尝试使这个贴图出现在同一个viewController的TableView上方。



在这个应用程序中,我使用Parse,数据到我的TableView,并工作正常。

我试图使用一些建议,我发现这里在StackOverflow,但问题仍然存在:



不能把谷歌地图GMSMapView放在主视图的子视图中?

如何设置框架的mapview - 谷歌GMSMap for iOS6的



显然这个问题与t有关他的方法:


$ b

  mapView_ = [GMSMapView mapWithFrame:CGRectZero camera :相机]; 

当我删除它时,错误消失。

我的TestViewController编码如下(没有表或任何东西,但仍然不起作用):

  // TesteViewController.m 

//



#importTesteViewController.h
#import< GoogleMaps /GoogleMaps.h>
#importAppDelegate.h

@interface TesteViewController()

@end

@implementation TesteViewController {
GMSMapView * mapView_;

$ b - (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
{
self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil ]。
if(self){
//定制初始化
}
返回self;
}

- (void)viewDidLoad
{
[super viewDidLoad];
//在加载视图后执行其他任何设置。


//创建一个GMSCameraPosition,告诉地图显示
GMSCameraPosition * camera = [GMSCameraPosition cameraWithLatitude:-33.86
longitude:151.20
zoom :6];
mapView_ = [GMSMapView mapWithFrame:CGRectZero camera:camera];
mapView_.myLocationEnabled = YES;
self.view = mapView_;

//在地图的中心创建一个标记。
GMSMarker * marker = [[GMSMarker alloc] init];
marker.position = CLLocationCoordinate2DMake(-33.86,151.20);
marker.title = @悉尼;
marker.snippet = @澳大利亚;
marker.map = mapView_;







$ b - (void)didReceiveMemoryWarning
{
[super didReceiveMemoryWarning];
//处理任何可以重新创建的资源。
}



@end

我还按照建议导入了所有框架,并且没有成功地将 -ObjC 放入我的 otherLinkerFlags 中。 / p>

除此之外,我测试了我在一个新的空白项目中使用的过程,并且它工作正常,但是当我尝试添加空白 viewController 就像对原始项目的测试一样,它不起作用。



我做的另一个测试是为此添加一个视图空白 viewController 并尝试在上面发布的StackOverflow引用中声明的内容。



有没有人对什么有什么建议发生?

也许与Parse的框架或其他库冲突?



而不是使用 -ObjC 我也试过 -force_load $(PROJECT_DIR)/ GoogleMaps .framework / GoogleMaps ,并且错误消失,它要求我允许我当前的位置,但屏幕不会加载。 方案

您需要做的是在您的项目构建设置中添加-objC标志,而不是目标的构建设置。



正如Google文档的以下部分所述

  **选择你的项目,而不是特定的目标,然后打开
Build Settings选项卡,在Other Linker标志部分添加-ObjC,如果
这些设置不可见,则更改过滤器从基本到全部构建
设置栏。**

通过这种方式,我能够解决Google Maps animateToCameraPosition问题。


I am trying to install Google Maps API to an app for iOS7. After following Google's guidelines and videos I ended up with the following error: [GMSMapView animateToCameraPosition:]: unrecognized selector sent to instance 0x10b98e6c0

I am using Storyboard, and trying to make this map appears above a TableView in the same viewController.

In this app, I use Parse, which is fetching data to my TableView, and is working fine.

I tried to use a couple of suggestions which I found here on StackOverflow, but the problem persists:

Cannot put a google maps GMSMapView in a subview of main main view?

How to set the frame for mapview - in google GMSMap for iOS6

Apparently the issue is related to this method:

mapView_ = [GMSMapView mapWithFrame:CGRectZero camera:camera];

When I erases it, the error goes away.

My TestViewController is coded as below(no table or anything, but still not working):

//  TesteViewController.m

//



#import "TesteViewController.h"
#import <GoogleMaps/GoogleMaps.h>
#import "AppDelegate.h"

@interface TesteViewController ()

@end

@implementation TesteViewController{
    GMSMapView *mapView_;
}

- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
{
    self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
    if (self) {
        // Custom initialization
    }
    return self;
}

- (void)viewDidLoad
{
    [super viewDidLoad];
    // Do any additional setup after loading the view.


    // Create a GMSCameraPosition that tells the map to display the
    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_;




}



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



@end

I also imported all frameworks, as recommended, and did put -ObjC into my otherLinkerFlags, without success.

In addition to that, I tested the process I am using in a new blank project and it worked fine, but, when I try to add a blank viewController just as a test to the original project, it does not work.

Another test I did, was to add a view to this blank viewController and try what is stated on StackOverflow's references I posted above.

Has anyone got any suggestions about what is happening?

Maybe a conflict with Parse's framework or some other library?

Instead of using -ObjC I also tried -force_load $(PROJECT_DIR)/GoogleMaps.framework/GoogleMaps and the error goes away, it asks me to allow my current position, but the screen does not load.

解决方案

What you have to do is to add -objC flag in your "project" build setting, instead of "target"'s build setting.

As it is mentioned in the following section from Google's Documentation

**" Choose your project, rather than a specific target, and open the
    Build Settings tab. In the Other Linker Flags section, add -ObjC. If
    these settings are not visible, change the filter in the Build
    Settings bar from Basic to All. "**

By this way, I was able solve Google Maps animateToCameraPosition issue.

这篇关于Google Maps animateToCameraPosition iOS7问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆