#import <UIKit/UIKit.h> #import <MapKit/MapKit.h> @interface T20140621000000ViewController : UIViewController<MKMapViewDelegate> @property (weak, nonatomic) IBOutlet MKMapView *mapView; @end
#import "T20140621000000ViewController.h" @interface T20140621000000ViewController () @end @implementation T20140621000000ViewController - (void)viewDidLoad { [super viewDidLoad]; if ([CLLocationManager locationServicesEnabled]) { _mapView.mapType = MKMapTypeStandard; _mapView.delegate = self; _mapView.showsUserLocation = YES; [_mapView setUserTrackingMode:MKUserTrackingModeFollow animated:YES]; } } - (void)didReceiveMemoryWarning { [super didReceiveMemoryWarning]; } #pragma mark - #pragma mark Map View Delegate Methods - (void)mapView:(MKMapView *)mapView didUpdateUserLocation:(MKUserLocation *)userLocation { _mapView.centerCoordinate = userLocation.location.coordinate; } - (void)mapViewDidFailLoadingMap:(MKMapView *)theMapView withError:(NSError *)error { NSLog(@"error : %@",[error description]); } @end