2015-08-28 71 views
0

我希望谷歌地圖僅顯示在屏幕的一半,並且還有其他項目要在屏幕的另一半中顯示。所以,我已將iPhone屏幕劃分爲兩個UIView,分別爲mapViewdetailView。當我嘗試在mapView中使用谷歌地圖時,它會給出空白屏幕。而當它被分配到self.view時,它會在整個屏幕中顯示地圖,如下所示。在特定視圖中顯示谷歌地圖

在圖形頁面沒有顯示

GMSCameraPosition *camera = [GMSCameraPosition cameraWithLatitude:-33.86 
                 longitude:151.20 
                  zoom:6]; 
GMSMapView *mapView_ = [GMSMapView mapWithFrame:CGRectZero camera:camera]; 
mapView_.myLocationEnabled = YES; 
self.mapView = mapView_; //Doesn't work 

// 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_; 
+0

我認爲問題出現在這一行** [GMSMapView mapWithFrame:CGRectZero camera:camera]; **。你必須給框架谷歌地圖 –

+0

試試這個http://stackoverflow.com/a/26778538/1702413 – TonyMkenu

回答

1

改變這一行:

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

要這樣:

GMSMapView *mapView_ = [GMSMapView mapWithFrame:self.mapView.frame camera:camera]; 

這應該解決您的問題,如果你適當地設置單獨的視圖並且應該匹配到該視圖框架。