还有人遇到过这种情况吗?我正在使用最新的iOS版谷歌地图SDK。这就是我在didTapInfoWindowOfMarker方法中的内容:
- (void)mapView:(GMSMapView *)mapView didTapInfoWindowOfMarker:(id<GMSMarker>)marker {
NSLog(@"yes");
}
在我的输出中没有任何响应。
听起来你没有为你的GMSMapView对象添加委托和协议,比如:
mapView_.delegate = self;
所以,完整的- (void)loadView
和delegate方法应该是:
@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.
}