ios - Check if user has selected another annotation in map -


i have map annotations performing following actions:

- (void)mapview:(mkmapview *)mapview diddeselectannotationview:(mkannotationview *)view{ [self methoda];}    - (void)mapview:(mkmapview *)mapview didselectannotationview:(mkannotationview *)view{ [self methodb];} 

both method , b remove or add views in mapview.superview.

all works fine when dealing 1 annotation. the problem when have more 1 annotation , select two, 1 after other.

if click anywhere else in map works fine. when click in second annotationview after first one, performs "diddeselectannotationview" , "didselectannotationview" calls both methods , b, , not want. detect clicking in annotation , ignore both methods.

i have researched haven't found solution yet.

i have tried add global variable , play identifying user touches:

-(void)touchesbegan:(nsset *)touches withevent:(uievent *)event{  uitouch *touch = [touches anyobject];  // specific point touched cgpoint point = [touch locationinview:self.mapview];  (id<mkannotation> annotation in self.mapview.annotations) {     mkannotationview* anview = [self.mapview viewforannotation: annotation];     if (anview){          cgrect frame = cgrectmake(anview.frame.origin.x-5, anview.frame.origin.y-5, anview.frame.size.width+5, anview.frame.size.height+5);         if ( cgrectcontainspoint(frame, point) ) {              nslog(@"belongs");         }      }  }} 

however, didn't catch touches plus bit of spaghetti solution.

any ideas how solve this?

all best

- (void)mapview:(mkmapview *)mapview didselectannotationview:(mkannotationview *)aview {     indexpathtag=aview.tag;     [mapview deselectannotation:aview.annotation animated:yes];  } - (void)mapview:(mkmapview *)mapview diddeselectannotationview:(mkannotationview *)aview { } 

call deselectannotation didselectannotationview.


Comments

Popular posts from this blog

ruby on rails - RuntimeError: Circular dependency detected while autoloading constant - ActiveAdmin.register Role -

c++ - OpenMP unpredictable overhead -

javascript - Wordpress slider, not displayed 100% width -