我正在嘗試將Google Maps API安裝到適用於iOS7的應用程序。在遵循Google的準則和視頻後,我結束了以下錯誤:[GMSMapView animateToCameraPosition:]: unrecognized selector sent to instance 0x10b98e6c0
Google Maps animateToCameraPosition iOS7問題
我正在使用Storyboard,並試圖使此映射出現在同一viewController的TableView上方。
在這個應用程序中,我使用Parse,它將數據提取到我的TableView,並且工作正常。
我試圖用一對夫婦,我發現這裏StackOverflow的建議,但問題仍然存在:
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
顯然,問題涉及到這個方法:
mapView_ = [GMSMapView mapWithFrame:CGRectZero camera:camera];
當我刪除它時,錯誤g遠離。
我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
和錯誤消失,它要求我允許我的當前位置,但屏幕無法加載。
不要在viewDidLoad中設置視圖!這是loadView的工作。因此,將地圖視圖創建代碼移動到loadView方法。 – Felix
@ phix23嘗試loadView,但得到了同樣的錯誤。另外,我試圖將其移至viewWillLayoutSubviews方法,錯誤消失,但我只得到一個黑色的視圖。 –
你在哪裏放置導致崩潰的代碼 - 即'[GMSMapView animateToCameraPosition:]'? – Adam