我使用带有Storyboard的Google Maps iOS SDK。应用程序从导航视图控制器开始,该控制器具有具有地图的根视图控制器。
@implementation MyViewController
@synthesize btnMyLock;
@synthesize btnNearby;
GMSMapView *mapView_;
- (void)viewDidLoad
{
[super viewDidLoad];
// Do any additional setup after loading the view, typically from a nib.
GMSCameraPosition *camera = [GMSCameraPosition cameraWithLatitude:20
longitude:20
zoom:0];
mapView_ = [GMSMapView mapWithFrame:CGRectZero camera:camera];
mapView_.myLocationEnabled = YES;
self.view = mapView_;
// Creates a marker in the center of the map.
GMSMarker *marker = [[GMSMarker alloc] init];
[marker setIcon:[UIImage imageNamed:@"pin"]];
marker.position = CLLocationCoordinate2DMake(-33.86, 151.20);
marker.title = @"Sydney";
marker.snippet = @"Australia";
marker.map = mapView_;
mapView_.settings.compassButton = YES;
[mapView_ addSubview:btnMyLock];
[mapView_ addSubview:btnNearby];
}
按钮btnMyLock推动表视图控制器。在iOS 7中,这是可以的。但是在iOS 6中,我的应用程序会崩溃。有时会出现EXC_BAD_ACCESS(code=1)或code=2的错误。