显示地图的视图称为MKMapView。该类包含很多功能,包括如何显示地图、注释和用户位置。使用MKMapView需要导入MapKit.framework框架,在头文件中导入<MapKit/MapKit.h>,同时还需要遵循MKMapViewDelegate委托协议。
1、添加地图
MKMapView *map = [[MKMapView alloc] initWithFrame:CGRectMake(0,0,320,480)];
map.delegate = self; //将他的委托设为自己的类
[self .view addSubView:map];