ios4 - Multiple sources for UIPickerView on textfield editing -


what have far is

@synthesize txtcountry,txtstate; int flgtextfield; - (bool)textfieldshouldbeginediting:(uitextfield *)textfield {      [pickerview reloadallcomponents];      // make new view, or want here     if(textfield == txtcountry || textfield == txtstate){         flgtextfield = textfield.tag;         [uiview beginanimations:nil context:null];         //[pvstate setframe:cgrectmake(0.0f, 199.0f, 320.0f, 216.0f)];         [uiview commitanimations];           return no;     }     else {         return yes;     }  } - (nsinteger)numberofcomponentsinpickerview:(uipickerview *)pickerview; {     return 1; }  - (nsinteger)pickerview:(uipickerview *)thepickerview numberofrowsincomponent:(nsinteger)component {      if(flgtextfield==1){         return [arrycountry count];     }     else {         return [arrystate count];     }  }  - (nsstring *)pickerview:(uipickerview *)thepickerview titleforrow:(nsinteger)row forcomponent:(nsinteger)component {      if(flgtextfield==1){         return [arrycountry objectatindex:row];     }     else{         return [arrystate objectatindex:row];     }  }   - (void)viewdidload {      arrycountry = [[nsmutablearray alloc] init];      arrystate = [[nsmutablearray alloc] init];      [arrycountry addobject:@" 100 "];      [arrycountry addobject:@" 200 "];      [arrycountry addobject:@" 400 "];      [arrycountry addobject:@" 600 "];      [arrycountry addobject:@" 1000 "];      [arrystate addobject:@" "];      [arrystate addobject:@" b "];      [arrystate addobject:@" c "];      [arrystate addobject:@" d "];      [arrystate addobject:@" e "];       [super viewdidload];  } 

in .m ,

@interface contact : uiviewcontroller <uipickerviewdelegate, uipickerviewdatasource> {      iboutlet uitextfield *txtcountry;     iboutlet uitextfield *txtstate;      nsmutablearray *arrycountry;     nsmutablearray *arrystate;     uipickerview *pickerview; } @property(nonatomic,retain) iboutlet uitextfield *txtcountry; @property(nonatomic,retain) iboutlet uitextfield *txtstate; 

in .h file

now text fields not editable , need or guidance, or tutorial on how connect uipicker multiple sources can change when text fields editing

so see no 1 cares :)

what have 3 textfields , whenever touch textfield1 or textfield2 picker changes values , there no keyboard. when touch textfield3 keyboard appears , picker goes hidden.now if dismiss keyboard clicking return , click textfield1 picker appears again, if dont dismiss keyboard clicking button stays on picker. need when keyboard firstresponder (and see on screen) hide if click on textfield1 , see picker

    int variabla;          -(void)textfielddidbeginediting:(uitextfield *)textfield{             [pickerview sethidden:yes];             if (textfield1.editing == yes) {                 [textfield1 resignfirstresponder];                 [pickerview sethidden:no];                 variabla = 1;             }else if (textfield2.editing == yes) {                   [textfield2 resignfirstresponder];                 [pickerview sethidden:no];                 variabla = 2;             }                nslog(@"variabla %d",variabla);              [pickerview reloadallcomponents];         }          - (nsinteger)numberofcomponentsinpickerview:(uipickerview *)pickerview;         {             return 1;         }         - (nsinteger)pickerview:(uipickerview *)pickerview numberofrowsincomponent:(nsinteger)component;         {             if (variabla == 1) {                 return [pickerarray1 count];             }else if (variabla == 2) {                 return [pickerarray2 count];             }else {                 return 0;             }            }         - (nsstring *)pickerview:(uipickerview *)pickerview titleforrow:(nsinteger)row forcomponent:(nsinteger)component;         {                if (variabla == 1) {                 return [pickerarray1 objectatindex:row];                     }else if (variabla == 2) {                 return [pickerarray2 objectatindex:row];             }else {                 return 0;             }            }         - (void)textfieldshouldreturn:(uitextfield *)textfield{              [textfield resignfirstresponder];         } - (void)viewdidload {     [super viewdidload];     [pickerview sethidden:yes];     pickerarray1 = [[nsmutablearray alloc] initwithobjects:@"0", @"1", @"2", nil];     pickerarray2 = [[nsmutablearray alloc] initwithobjects:@"3", @"4", @"5", nil]; } 

Comments

Popular posts from this blog

asp.net - repeatedly call AddImageUrl(url) to assemble pdf document -

java - Android recognize cell phone with keyboard or not? -

iphone - How would you achieve a LED Scrolling effect? -