2015-09-07 62 views
1

我有一個DetailViewController,當用戶點擊mapView_上的時,將顯示DetailViewController。最初,我加載VC並將其設置爲隱藏狀態,當用戶點擊時,我會在VC中加載值並顯示它。但它沒有發生。這是我的代碼。ViewController在Google Map didTapMarker方法中未顯示 - iOS

@property (strong, nonatomic) GMSMapView *mapView;

- (void)viewDidLoad 
{ 
    [super viewDidLoad]; 

    _whisperDetailView.hidden = YES; 

    [_whisperDetailView initlize]; 
    _whisperDetailView.viewController = self; 

    GMSCameraPosition *camera = [GMSCameraPosition cameraWithLatitude:-33.86 
                  longitude:151.20 
                   zoom:6]; 
    mapView_ = [GMSMapView mapWithFrame:CGRectZero camera:camera]; 
    mapView_.myLocationEnabled = YES; 
    self.view = mapView_; 
} 



- (BOOL)mapView:(GMSMapView *)mapView didTapMarker:(GMSMarker *)marker 
{ 

    _detailView.whisper = marker.userData; 
    _detailView.hidden = NO; 

    return YES; 
} 

故事板的快照:Storyboard

有趣的是我用Mapbox之前,並在其didSelectAnnotation功能在做同樣的事情,一切是偉大的工作。我最近不得不切換到谷歌地圖,現在它不工作。

任何幫助表示讚賞。謝謝。

回答

0

好吧我現在已經工作了!發佈答案讓其他人陷入了同樣的情況:

我改變了我添加我的mapView_的方式。而不是viewDidLoad分配self.view = mapView,我插mapView作爲一個子視圖我的主要view,像這樣:

mapView_ = [GMSMapView mapWithFrame:CGRectMake(0, 0, self.view.bounds.size.width, self.view.bounds.size.height) camera:camera]; 
[self.view insertSubview:mapView_ atIndex:0]; 

唉!現在一切都像魅力一樣運作!當我點擊一個標記,我的DetailViewController顯示正確的大小,並在我設置故事板。

相關問題