2013-02-28 162 views

回答

5

聽起來像是你沒有添加委託和協議爲您GMSMapView中的對象,是這樣的:在的loadView方法

mapView_.delegate = self; 

因此,充分- (void)loadView和委託方法應該是:

@interface ViewController() <GMSMapViewDelegate> // Add this if you haven't 
{ 
    id<GMSMarker> myMarker; 
} 


- (void)loadView { 
    GMSCameraPosition *camera = [GMSCameraPosition cameraWithLatitude:-33.8683 
                  longitude:151.2086 
                   zoom:6]; 
    mapView_ = [GMSMapView mapWithFrame:CGRectZero camera:camera]; 
    mapView_.myLocationEnabled = YES; 
    mapView_.delegate = self; // This sets the delegate for map view 
    self.view = mapView_; 
} 

- (void)mapView:(GMSMapView *)mapView didTapInfoWindowOfMarker:(id<GMSMarker>)marker { 
    NSLog(@"yes"); // And now this should work. 
} 
+2

非常感謝!感覺像一個白癡忘記設置其代表:( – kevnguy 2013-03-01 00:24:38