I've a MKMapView that I expand and contract with code like this:
UIView.animate(withDuration: 0.5) {
mapView.frame = CGRect(x: 0, y: 0, width: 200, height: 400)
}
Before IOS 11 the above code would trigger regionDidChangeAnimated
delegate method after animation was completed. It would change its region and let zoom level be.
In IOS 11 just the zoom changes. None of the delegate methods are triggered.
I need to have it like before. Changing maps frame should just make the visible area bigger without zoom change.
I've tried to set mapView.isZoomEnabled = false
before altering mapViews frame, but the zoom level keeps changing.
Update:
I added two animated GIFs to compare IOS 11 with previous IOS versions.
IOS 11 will zoom in immediately before expand animation starts. It will zoom out after the reverse animation is completed.
As you see below the IOS 9 animation is smooth as silk.
IOS 11:
IOS 9:
The easiest way to get an Integer of the current zoom level, is by using the MapView function: regionDidChangeAnimated. This function recognizes every change in zoom and will give you the basis for the calculation of the zoom factor.
The MKMapView class supports the ability to annotate the map with custom information. Because a map may have large numbers of annotations, map views differentiate between the annotation objects used to manage the annotation data and the view objects for presenting that data on the map.
Found a solution! More of a hack:
Center the MapView on Y and give the MapView a fixed height, I used: UIScreen.main.bounds.size.height
.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With