ios - Telling the difference between UserLocation Pin and user added pins -


i trying solve problem i'm not sure how solve. in app, when mapkit launches, drop pin @ user's current location. mapkit delegates viewforannotation sets pin's color works fine.

the issue i'm running cannot tell annotations apart can apply different color "user added locations" vs. "current location" pin. add button can delete pins add not able delete "current location" pin. can't seem figure out how extract identifiable pieces of information title or subtitle of pin.

thanks in advance help.

here's code...

    - (mkannotationview *)mapview:(mkmapview *)mapview viewforannotation:(id <mkannotation>)annotation {     nslog(@"oaassignmentgpsviewcontroller.m : mapview viewforannotation");      if([annotation iskindofclass: [mkuserlocation class]])     return nil;      nslog(@" mapview.userlocation.title = %@", self.mapview.userlocation.title);     static nsstring* annotationidentifier = @"currentlocation";     mkpinannotationview *mypinview = (mkpinannotationview *)[self.mapview dequeuereusableannotationviewwithidentifier:annotationidentifier];     if (!mypinview) {     mypinview = [[mkpinannotationview alloc] initwithannotation:annotation reuseidentifier:nil] ;     mypinview.pincolor = mkpinannotationcolorred;     mypinview.canshowcallout = yes;     mypinview.animatesdrop = yes;      nslog(@"mapview.description %@", self.mapview.userlocation.title);     if( annotation   != self.mapview.userlocation)<<<<<----how check userlocation     {         mypinview.pincolor = mkpinannotationcolorgreen;         mypinview.rightcalloutaccessoryview =   [uibutton buttonwithtype:uibuttontypedetaildisclosure];     }    }     return mypinview; } 

the thing can think of subclass mkpinannotationview , add simple property index it. add pins array they're created , increment index number. then, "delete pins" method, check index property of pin make sure it's not first one:

-(ibaction)deleteallpins {    (id pin in self.pinsarray) {       if (pin.indexnumber >= 1) { //this not first pin...          // delete pin     }    } } 

that's try, anyway. sorry don't have time test out myself. started. luck.


Comments

Popular posts from this blog

Why does Ruby on Rails generate add a blank line to the end of a file? -

keyboard - Smiles and long press feature in Android -

node.js - Bad Request - node js ajax post -