我正在尝试将 Google Maps API 安装到 iOS7 的应用程序中。在遵循 Google 的指南和视频后,我最终遇到了以下错误:[GMSMapView animateToCameraPosition:]: unrecognized selector sent to instance 0x10b98e6c0
我正在使用 Storyboard,并尝试使该地图显示在同一 viewController 中的 TableView 上方。
在此应用程序中,我使用 Parse,它将数据提取到我的 TableView,并且工作正常。
我尝试使用在 StackOverflow 上找到的一些建议,但问题仍然存在:
无法将谷歌地图 GMSMapView 放在主主视图的子视图中?
如何设置地图视图的框架 - 在 iOS 6 的谷歌 GMS 地图中
显然这个问题与此方法有关:
mapView_ = [GMSMapView mapWithFrame:CGRectZero camera:camera];
当我删除它时,错误就消失了。
我的 TestViewController 编码如下(没有表格或任何东西,但仍然无法工作):
// 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
我还按照建议导入了所有框架,并放置了-ObjC
进入我的otherLinkerFlags
, 没有成功。
除此之外,我测试了在新的空白项目中使用的过程,它工作得很好,但是,当我尝试添加空白时viewController
只是作为对原始项目的测试,它不起作用。
我做的另一个测试是向这个空白添加一个视图viewController
并尝试我上面发布的 StackOverflow 参考文献中所述的内容。
有人对正在发生的事情有什么建议吗?
也许与 Parse 的框架或其他库有冲突?
而不是使用-ObjC
我也尝试过-force_load $(PROJECT_DIR)/GoogleMaps.framework/GoogleMaps
并且错误消失了,它要求我允许我的当前位置,但屏幕未加载。