问题
Anyone else experiencing this? I'm using the latest Google Maps SDK for iOS. This is what I have in the didTapInfoWindowOfMarker method :
- (void)mapView:(GMSMapView *)mapView didTapInfoWindowOfMarker:(id<GMSMarker>)marker {
NSLog(@"yes");
}
Not getting any response in my output.
回答1:
Sounds like you didn't add delegate and protocol for your GMSMapView object, something like:
mapView_.delegate = self;
in loadView method.
So, the full - (void)loadView
and delegate method should be:
@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.
}
来源:https://stackoverflow.com/questions/15125158/mapview-didtapinfowindowofmarker-method-does-not-work-google-maps-ios-sdk