我使用带有情节提要的谷歌地图 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 推动 Table View Controller。在 iOS 7 中没问题。但是 iOS 6 我的应用程序崩溃了。有时会因 EXC_BAD_ACCESS (code=1) 或 code=2 崩溃