使用MapKit框架
地图显示
最简单显示地图的代码:
// // RootViewController.m // CoreLocation // // Copyright (c) 2014年 Y.X. All rights reserved. // #import "RootViewController.h" #import <MapKit/MapKit.h> @interface RootViewController () @end @implementation RootViewController - (void)viewDidLoad { [super viewDidLoad]; // 初始化地图控件 MKMapView *mapView = [[MKMapView alloc] initWithFrame:self.view.bounds]; // 地图的类型 mapView.mapType = MKMapTypeStandard; // 视图的宽度和高度将和父视图的宽度一起成比例变化 mapView.autoresizingMask = \ UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight; // 显示地图 [self.view addSubview:mapView]; } @end