i'm not sure if i'm going right way, i'll first explain i'm trying do.
i generating buttons using data array of annotation objects.
i want user able click on button, have textfield appear, , whatever type overwrite text in relevant annotation object , button.
so have buttons being generated annotation data, stuck.
//make button each annotion if x value within 0 - 1400 boundary. for(annotation * ack in markerpoints) { if ([ack x] > 0 && [ack x] < 1401) { uibutton * marker = [uibutton buttonwithtype:uibuttontyperoundedrect]; [marker addtarget:self action:@selector(markerpressed:) forcontrolevents:uicontroleventtouchdown]; marker.frame=cgrectmake([ack x],[ack y],100,50); [marker settitle:[ack textdata] forstate:uicontrolstatenormal ]; [marker settitlecolor:[uicolor blackcolor] forstate:uicontrolstatenormal]; [marker setbackgroundcolor:[uicolor whitecolor]]; [self addsubview:marker ]; [markerbuttonlist addobject:marker]; } }
when user presses button, how can tell annotation object related can change annotation textdata?
you can set tag of each button array index value , fetch tag in method when called. example:
//make button each annotion if x value within 0 - 1400 boundary. nsinteger index = 0; for(annotation * ack in markerpoints) { if ([ack x] > 0 && [ack x] < 1401) { uibutton * marker = [uibutton buttonwithtype:uibuttontyperoundedrect]; [marker addtarget:self action:@selector(markerpressed:) forcontrolevents:uicontroleventtouchdown]; marker.frame=cgrectmake([ack x],[ack y],100,50); [marker settitle:[ack textdata] forstate:uicontrolstatenormal ]; [marker settitlecolor:[uicolor blackcolor] forstate:uicontrolstatenormal]; [marker setbackgroundcolor:[uicolor whitecolor]]; [market settag:index]; [self addsubview:marker ]; [markerbuttonlist addobject:marker]; } index++; } -(void)markerpressed:(uibutton*)sender{ annotation * ack_selected = [markerpoints objectatindex:sender.tag]; }
Comments
Post a Comment