-1

好吧,我试着解释我的问题:

  1. 我从 GMSMapView 子类化了 MyMapView

    @interface MyMapView : GMSMapView @end

  2. 现在我在 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; }

  3. 在 MyViewController.hi 中声明了 GMSMapViewDelegate

    @interface MyViewController : UIViewController <GMSMapViewDelegate> @end

现在我想在 MyViewController 中使用一些 GMSMapViewDelegate-Methods 但我尝试的所有方法都出错了。谁能解释我在这种情况下如何使用 GMSMapViewDelegate-Methods?

谢谢,格雷西。

4

1 回答 1

0

所以我通过将委托添加到子类和视图控制器来解决问题

@interface MyMapView : GMSMapView <GMSMapViewDelegate>
@end

@interface MyViewController : UIViewController <GMSMapViewDelegate>
@end

在此之后,您可以在视图控制器中使用委托方法。

于 2014-09-18T20:40:34.330 回答