ios - How to display UIlabel with string format when selecting data from a UIPickerview -
hi have 1 picker view. picker view web services came loading data. picker view 2 part. picker view 1. part project name. , picker view 2. part project number. when open screen project no label no data. when open screen project name label no data. when rotate picker view came data proje adı: "a1 unitesi" proje no: "002". how can when open screen came data rotate picker ?
when open screen project name , project no labels no data. want came data when open screen
when rotate picker view came data this.
- (nsinteger)numberofcomponentsinpickerview:(uipickerview *)pickerview { return 2; } - (nsinteger)pickerview:(uipickerview *)pickerview numberofrowsincomponent:(nsinteger)component { if (component == 0) { return [raporlarlist count]; } return [raporlarlist count]; } #pragma mark picker delegate methods - (nsstring *)pickerview:(uipickerview *)pickerview titleforrow:(nsinteger)row forcomponent:(nsinteger)component { if (component == 0) { eobje = [raporlarlist objectatindex:row]; return eobje.projeadii; } eobje = [raporlarlist objectatindex:row]; return eobje.projenoo; } #pragma mark - #pragma mark pickerview delegate -(void)pickerview:(uipickerview *)pickerview didselectrow:(nsinteger)row incomponent:(nsinteger)component { if (component == 0) { nsstring *resultstring = [[nsstring alloc] initwithformat:@"proje adı : %@", [[raporlarlist objectatindex:row] projeadii]]; lblprojeadi.text = [nsstring stringwithformat:@"%@", resultstring]; } else { nsstring *resultstring = [[nsstring alloc] initwithformat:@"proje no: %@", [[raporlarlist objectatindex:row] projenoo]]; lblprojeno.text = resultstring; } }
you have selected wrong datasource pickerview.
you returning string, instead return label
- (uiview *)pickerview:(uipickerview *)pickerview viewforrow:(nsinteger)row forcomponent:(nsinteger)component { // return uilabel }
Comments
Post a Comment