简体   繁体   English

iOS Swift MapKit将不会重新加载

[英]iOS Swift MapKit will not reload

I have a MapKit View on my storyboard - set to hidden. 我的情节提要板上有一个MapKit视图-设置为隐藏。 With the following code I can unhide it from view using a button(1) click and it loads perfectly. 使用以下代码,我可以使用button(1)单击取消隐藏它,并且可以完美加载。 Another button(2) click will hide the map. 再次单击按钮(2)将隐藏地图。 The issue is reloading the map. 问题是重新加载地图。 How do I reload the map with button(1). 如何使用button(1)重新加载地图。 Currently, the map will not show again. 目前,该地图将不再显示。

Here is the entire code to load the map: 这是加载地图的完整代码:

@IBAction func ButtonOne(sender: UIButton) {
    self.myMap()

}//End Button(1)

@IBAction func ButtonTwo(sender: UIButton) {
    self.mapView.hidden = true

}//End Button(2)

func myMap() {
    let userLocation = self.mapView.userLocation

    let region = MKCoordinateRegionMakeWithDistance(
        userLocation.location.coordinate, 2000, 2000)

    self.mapView.hidden = false
    self.mapView.frame = CGRect(x: 0, y: 0, width: screenSize.width, height: screenSize.height * 0.75)
    self.mapView.setRegion(region, animated: true)
}

I am just going to use 'exit(1)' when disconnecting/hiding then map when the call ends. 我只是在断开连接/隐藏时使用“ exit(1)”,然后在通话结束时使用map。 BTT the user will really have no use for still being able to use the app. BTT用户仍然无法使用仍然可以使用该应用程序。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM