ios - How set UIPickerView in cascade -
i'm trying set 2 uipickerview
s, both filled nsdictionary
, work ok, need second uipickerview
implement refresh depends of selection of first uipickerview
, understand me?
the first uipickerview
filled way:
for (nsdictionary *local in json) { nsstring *nombre = [local objectforkey:@"name"]; nsstring *idlocal = [local objectforkey:@"id"]; self.diclocales = [nsdictionary dictionarywithobjectsandkeys: idlocal, @"idlocal", nombre, @"nombrelocal", nil]; [listalocales addobject:self.diclocales]; }
and second uipickerview
filled way:
for (nsdictionary *servicio in json) { nsstring *nombre = [servicio objectforkey:@"name"]; nsstring *idservicio = [servicio objectforkey:@"id"]; self.dicservicios = [nsdictionary dictionarywithobjectsandkeys: idservicio, @"idservicio", nombre, @"nombreservicio", idlocal, @"idlocal", nil]; [listaservicios1 addobject:self.dicservicios]; }
you note variable idlocal
, corresponds id of first uipickerview
rows. then, need, if in first uipickerview
selected row idlocal 1, in second uipickerview
reloaded or refreshing rows corresponds idlocal 1.
please hope can me, , sorry english :p
you have implement <uipickerviewdelegate>
method below
- (void)pickerview:(uipickerview *)pickerview didselectrow:(nsinteger)row incomponent:(nsinteger)component { if ([pickerview isequal:firstpickerview]) { //secondpickerview fill code [secondpickerview reloadallcomponents]; } else { //secondpickerview selected row } }
and change second uipickerview fill loop accordingly
Comments
Post a Comment