2013-08-01 49 views
2

我正在使用Google Maps iOS API。沒有任何委託方法正在解僱。我如何讓他們工作?GMSMapViewDelegate方法不被調用?

MapViewController.h:

@interface MapViewController : UIViewController <GMSMapViewDelegate> 
@property (strong, nonatomic) IBOutlet GMSMapView *mapView_; 

@end 

#import "MapViewController.h" 
#import <GoogleMaps/GoogleMaps.h> 
@interface MapViewController() 

@end 

MapViewController.m @implementation的MapViewController @synthesize mapView_; GMSCircle * circ;

- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil 
{ 
self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil]; 
if (self) { 
    // Custom initialization 
} 
return self; 
} 

- (void)viewDidLoad 
{ 
[super viewDidLoad]; 

// Do any additional setup after loading the view. 
} 

- (void)loadView { 
mapView_.delegate = self; 

GMSCameraPosition *camera = [GMSCameraPosition cameraWithLatitude:10 
                 longitude:10 
                  zoom:15]; 
mapView_ = [GMSMapView mapWithFrame:CGRectZero camera:camera]; 
mapView_.myLocationEnabled = YES; 
self.view = mapView_; 

mapView_.mapType = kGMSTypeHybrid; 

CLLocationCoordinate2D circleCenter = CLLocationCoordinate2DMake(10, 10); 
GMSCircle *circ = [GMSCircle circleWithPosition:circleCenter 
             radius:10]; 
circ.tappable = true; 
[circ setFillColor:[UIColor colorWithRed:1 green:0 blue:0 alpha:.5]]; 

circ.map = self.mapView_; 

} 

- (void)didReceiveMemoryWarning 
{ 
[super didReceiveMemoryWarning]; 
// Dispose of any resources that can be recreated. 
} 

- (void)mapView:(GMSMapView *)mapView didTapOverlay:(GMSOverlay *)overlay 
{ 
NSLog(@"in didTapOverlay"); 

[overlay isKindOfClass:[circ class]]; 
if ([overlay isKindOfClass:[circ class]]) { 
     GMSMarker *marker = [[GMSMarker alloc] init]; 
     marker.position = CLLocationCoordinate2DMake(10, 10); 
     marker.title = @"Place"; 
     marker.snippet = @"Sub Place"; 
     marker.map = mapView_; 

} 
} 


- (void) mapView:(GMSMapView *) mapView willMove:(BOOL) gesture 
{ 
NSLog(@"In willMove"); 
} 
@end 

回答

7

我認爲你是委託屬性設置爲早期

試試這個:

GMSCameraPosition *camera = [GMSCameraPosition cameraWithLatitude:10 
                 longitude:10 
                  zoom:15]; 
mapView_ = [GMSMapView mapWithFrame:CGRectZero camera:camera]; 
mapView_.myLocationEnabled = YES; 
mapView_.delegate = self; 
self.view = mapView_; 
+0

我無法改變地圖 –

2

設置委託在viewDidLoad中

+0

的類型更詳細一點 - 代碼更改的一個簡單示例? –