Tuesday, June 23, 2015

MKMapView - Map without using the Storyboard

1. Add MapKit and CoreLocation frameworks to the project targets.



2. Complete the code as below:

import UIKit
import CoreLocation
import MapKit

class ViewController: UIViewController {

    override func viewDidLoad() {
        super.viewDidLoad()
        
        var myMapView = MKMapView(frame: self.view.bounds)
        
        myMapView.mapType = MKMapType.Standard
        
        self.view.addSubview(myMapView)
    }

    override func didReceiveMemoryWarning() {
        super.didReceiveMemoryWarning()
        // Dispose of any resources that can be recreated.
    }


}

No comments:

Post a Comment