从MapView执行Segue时应用程序崩溃

时间:2015-11-12 20:28:31

标签: ios swift mkmapview segue

我开发的应用程序包含地图视图,一切正常。我可以与地图等进行互动。

然而,当我点击我放置在地图视图下的按钮以仅使用一些标签和开关在设置视图中执行segue时,我得到了Swift的可选展开错误:

fatal error: unexpectedly found nil while unwrapping an Optional value

错误发生在我为初始视图创建的地图视图上,当我检查调试控制台时,地图视图似乎为nil,因为错误消息有关。

为什么segue关心地图视图被解除分配并引发异常?我该如何解决这个问题?

我的代码&故事板:

override func viewDidLoad() {
    super.viewDidLoad()

    locationManager = CLLocationManager()
    locationManager.requestWhenInUseAuthorization()
    locationManager.desiredAccuracy = kCLLocationAccuracyBest
    locationManager.startUpdatingLocation()

    self.configureFloorPlan()
}

func configureFloorPlan() {
    ...
    // the crash happens at the following line of code when I press the button
    mapView.addOverlay(HideBackgroundOverlay.hideBackgroundOverlay(), level: .AboveRoads)
    ...
}

当我按下初始视图控制器左下角的信息按钮时,会启动segue。

enter image description here

当我删除目标视图控制器的类时,崩溃将解决。这是有趣的,因为目前该课程是空的。

0 个答案:

没有答案
相关问题