Hamish
Hamish

Reputation: 1745

How to stop MapView from automatic scroll?

I have a MKMapView and some MKAnnotation. I want to select one of the MKAnnotation whenever user click on an item of my UICollectionView. this is my code for selecting one of the MKAnnotation.

func showAnnotationForItemAt(index: Int){
    for item in map.annotations{
        if item.title == items[index]["title"].string{
            map.selectAnnotation(item, animated: true)
            break
        }
    }
}

it works perfectly on iOS 12. but in iOS 10.3, map scrolls automatically to the annotation whenever I call map.selectAnnotation(item, animated: true). How can I prevent map from auto scrolling after calling selectAnnotation. I want it to be like what it happens in iOS 12

Upvotes: 0

Views: 267

Answers (1)

Jogendar Choudhary
Jogendar Choudhary

Reputation: 3494

Please do animation false:

map.selectAnnotation(item, animated: false)

Upvotes: 2

Related Questions