ios - Pairing MKAnnotation to UITableViewCell -
im trying establish link between custom mkannotationviews on map, , custom uitableviewcells.
so far i've initiated every cell mkannotationview , assigned tag of mkannotationview index.row of cell, , added nsmutablearray. i've tested , works- each mkannotationview linked appropriate uitableviewcell based on tag values , array position.
the problem: when user scrolls table , cell relating mkannotationview goes out of frame, seems being dequeued? mkannotationview tag gets reset, although pin stays on map. although have managed text persist in cells of uitableviewcells using array isn't working mkannotationviews.
what best method me create relationship between mkannotationviews on map , uitableviewcells?
i suggest problem trying use views store logic. if understand correctly, must have array of objects should represented 2 ways - list of cells , set of annotations on map.
uitableviewcell
s mkannotationviews reusable, views display information @ point of time. no need stick on that.
every uitableviewcell
has object in datasource behind it. every mkannotationview
has id<mkannotation>
object behind it.
so can have array (which ordered) of <mkannotation>
-compatible objects , use array datasource uitableview
.
if @ point of time need find corresponding cell , annotationview, can use objectatindex
:.
Comments
Post a Comment