Google Maps animateToCameraPosition iOS7 issue

心已入冬 提交于 2019-12-02 12:39:55

问题


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.


回答1:


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.



来源:https://stackoverflow.com/questions/23170851/google-maps-animatetocameraposition-ios7-issue

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!