iphone - 1St value does not select in picker view -
hi iam having buttons when click 1 button picker view apper not select first value if scroll fist value selected plz me
here code
- (void)pickerview:(uipickerview *)thepickerview didselectrow:(nsinteger)row incomponent:(nsinteger)component { switch (tagvlaue) { case 0: { if(gender==yes) { nslog(@"selected color: %@. index of selected color: %i", [checkarray objectatindex:row], row); selectedgender=[checkarray objectatindex:row]; nslog(@"selected checkgender %@",selectedgender); genderlabel.text=selectedgender; // checkgender=no; } else { nslog(@"selected color: %@. index of selected color: %i", [genderarray objectatindex:row], row); selectedgender=[genderarray objectatindex:row]; nslog(@"selected gender %@",selectedgender); genderlabel.text=selectedgender; // checkgender=yes; } //genderlabel } break; case 1: { if(gender==no) { nslog(@"selected color: %@. index of selected color: %i", [seekingarray objectatindex:row], row); selectedseek=[seekingarray objectatindex:row]; nslog(@"selected seeking %@",selectedseek); seeklabel.text=selectedseek; } else { nslog(@"selected color: %@. index of selected color: %i", [seekcheckarray objectatindex:row], row); selectedseek=[seekcheckarray objectatindex:row]; nslog(@"selected seeking %@",selectedseek); seeklabel.text=selectedseek; } } break; case 2: nslog(@"selected color: %@. index of selected color: %i", [agearray objectatindex:row], row); selectedage=[agearray objectatindex:row]; nslog(@"selected age %@",selectedage); label.text=selectedage; break; case 3: nslog(@"selected color: %@. index of selected color: %i", [feetarray objectatindex:row], row); selectedheight=[feetarray objectatindex:row]; nslog(@"selected height %@",selectedheight); heightlabel.text=selectedheight; break; case 4: nslog(@"selected color: %@. index of selected color: %i", [weightarray objectatindex:row], row); selectedweight=[weightarray objectatindex:row]; nslog(@"selected weight %@",selectedweight); weightlabel.text=selectedweight; break; case 5: nslog(@"selected color: %@. index of selected color: %i", [enthnicityarray objectatindex:row],row); selectedethnicity=[enthnicityarray objectatindex:row]; nslog(@"selected weight %@",selectedethnicity); ethnicitylabel.text=selectedethnicity; break; case 6: nslog(@"selected color: %@. index of selected color: %i", [typearray objectatindex:row],row); selectedtype=[typearray objectatindex:row]; nslog(@"selected weight %@",selectedtype); typelabel.text=selectedtype; break; default: break; }
thanks advance
the delegate method:
- (void)pickerview:(uipickerview *)pickerview didselectrow:(nsinteger)row incomponent:(nsinteger)component;
is called when user explicitly select value in picker. must value selected in picker when picker first displayed yourself. example can @ picker data source.
Comments
Post a Comment