MKUserTrackingBarButtonItem when press will not zoom to current location

Discussion in 'iOS Programming' started by freakmoister, Apr 22, 2012.

  1. freakmoister macrumors newbie

    Dec 2, 2011
    I'm trying to figure out why the track bar button won't move the map back to user current location. It just changes to the waiting spin wheel (picture below) and the map doesn't move either. thanks.


    Part of my code below. The co-ords there is for the city centre, but I've set my simulator's location to another place, so if I click on the track bar button I expect to move there.
        - (void)viewDidLoad
            [super viewDidLoad];
            [self focusMap];
            self.mapView.showsUserLocation = YES;
        - (void) focusMap 
            CLLocationCoordinate2D coord = { -33.882365, 151.211025 };
            MKCoordinateSpan span = {0.005,0.005};
            MKCoordinateRegion region = {coord, span};
            [mapView setRegion: region animated: YES];
            MKUserTrackingBarButtonItem* trackerButton = [[MKUserTrackingBarButtonItem alloc] initWithMapView: self.mapView];
            self.navigationItem.rightBarButtonItem = trackerButton;
            [trackerButton release];
            mapView.zoomEnabled = YES;
  2. cMacSW macrumors regular

    Mar 20, 2006
    Did you try moving "mapView.zoomEnabled = YES;" before setting the location?

Share This Page