Google Maps iOS SDK Fails

I am using Google Maps iOS SDK with storyboard. An application starting with a navigation view controller with a root view controller with a map.

@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]; } 

The btnMyLock button presses the table view controller. On iOS 7, this is normal. But iOS 6 my application crashes. Sometimes a crash with EXC_BAD_ACCESS (code = 1) or code = 2

+3
source share
4 answers

The problem is that I used the Autolayout view.

+1
source

you forgot step 4: " Drag and Drop GoogleMaps.bundle " from the "Resources" folder into your project.

I suggest putting it in the Frameworks group. When prompted, make sure that “Copy items to target groups folder” is not selected. I ran into the same problem and this fixed it.

0
source

I don’t know if this caused a problem, but I wouldn’t do this:

 self.view = mapView_; 

Just add mapView_ to the subtitle, for example:

 [self.view addSubview:mapView_]; 

In general, EXC_BAD_ACCESS crashes occur when you incorrectly manage memory (for example, an object is freed prematurely). Try to figure out which object is crashing.


Create your buttons in code, not in xib like IBOutlets. Otherwise, they do not load, since you are not using xib.

0
source

Use this code when you use a Google map, and then check if it is missing when switching to another screen.

 - (void)dealloc { [super dealloc]; [mapView_ removeObserver:self forKeyPath:@"myLocation" context:NULL]; } 
0
source

All Articles