添加 MKMapView

迅速

let mapView = MKMapView(frame: CGRect(x: 0, y: 0, width: 320, height: 500))

建议将 mapView 存储为包含 ViewController 的属性,因为你可能希望在更复杂的实现中访问它。

目标 C.

self.map = [[MKMapView alloc]initWithFrame:CGRectMake(0, 0, self.view.frame.size.width, self.view.frame.size.height)];
[self.view addSubview:self.map];