wayn
wayn

Reputation: 1

is it possible to add annotation but do not change map view region in ios

I want to use regionDidChangeAnimated delegate get current region then request data from server and add new annotation, but when add new annotation the mapView's region will changed also, so this will loop forever?Anybody help?

Upvotes: 0

Views: 151

Answers (2)

Nicu Surdu
Nicu Surdu

Reputation: 8321

The map region changes if the callout for that annotation will change. Otherwise, you're moving it yourself from code to fit all the annotations in view, maybe ?

In either case, use a BOOL variable to indicate that the map will move because of the code, and in the delegate method check if the map was moved by the user or by your code.

Upvotes: 0

CSmith
CSmith

Reputation: 13458

MapView addAnnotation does not change a maps region. [MapView setRegion] does, as does a user via the UI.

If you're doing these server round-trips, you should only add the annotation if its going to be visible (based on the currently visible region), and don't do setRegion.

Upvotes: 1

Related Questions