简体   繁体   中英

iOS Swift MapKit will not reload

I have a MapKit View on my storyboard - set to hidden. With the following code I can unhide it from view using a button(1) click and it loads perfectly. Another button(2) click will hide the map. The issue is reloading the map. How do I reload the map with 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. BTT the user will really have no use for still being able to use the app.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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