好吧,我试着解释一下我的问题:
我从GMSMapView
中细分了MyMapView @interface MyMapView : GMSMapView
@end
现在我在MyViewController.m中使用MyMapView来显示GMSMap并设置委托GMSMapViewDelegate。
@implementation MyViewController
IBOutlet MyMapView *mapView;
}
-(void)viewDidLoad
{
[super viewDidLoad];
GMSCameraPosition *camera = [GMSCameraPosition cameraWithLatitude:-33.86
longitude:151.20
zoom:6];
mapView = [MyMapView mapWithFrame:CGRectZero camera:camera];
self.view = mapView;
mapView.delegate = self;
}
在MyViewController.h中,我声明了GMSMapViewDelegate
@interface MyViewController : UIViewController <GMSMapViewDelegate>
@end
现在我想在MyViewController中使用一些GMSMapViewDelegate-Methods但我尝试了所有错误。谁能解释一下如何在这种情况下使用GMSMapViewDelegate-Methods?
谢谢,grethi。
答案 0 :(得分:0)
所以我通过将委托添加到子类AND到视图控制器
来解决了这个问题@interface MyMapView : GMSMapView <GMSMapViewDelegate>
@end
@interface MyViewController : UIViewController <GMSMapViewDelegate>
@end
在此之后,您可以使用视图控制器中的委托方法。