I have created custom view like this:

```
import UIKit
import MapKit

class MapViewController: UIViewController {

    var mapView: MKMapView!

    func mapTypeChanged(segControl: UISegmentedControl){
        switch segControl.selectedSegmentIndex {
        case 0:
            mapView.mapType = .standard
        case 1:
            mapView.mapType = .hybrid
        case 2:
            mapView.mapType = .satellite
        default:
            break
        }

    }
    override func loadView() {
        mapView = MKMapView()

        view = mapView

        let segmentedControl = UISegmentedControl(items: ["Standard", "Hybrid", "Satellite"])

        segmentedControl.backgroundColor = UIColor.white.withAlphaComponent(0.5)

        segmentedControl.selectedSegmentIndex = 0

            segmentedControl.addTarget(self, action: "mapTypeChanged", for: .valueChanged)

        segmentedControl.translatesAutoresizingMaskIntoConstraints = false

        view.addSubview(segmentedControl)

        let topConstraint = segmentedControl.topAnchor.constraint(equalTo: topLayoutGuide.bottomAnchor, constant: 8)

        let margins = view.layoutMarginsGuide

        let leadingContraint = segmentedControl.leadingAnchor.constraint(equalTo: margins.leadingAnchor)

        let trailingConstraint = segmentedControl.trailingAnchor.constraint(equalTo: margins.trailingAnchor)

        topConstraint.isActive = true
        leadingContraint.isActive = true
        trailingConstraint.isActive = true

    }

} 

```

There are no build issues. but when I run the app and tap on any button on segmented control, it aborts the app. Not able to figure out what is the issue. I am using Xcode 9 beta.