What i have so far is
@synthesize txtCountry,txtState;
int flgTextField;
- (BOOL)textFieldShouldBeginEditing:(UITextField *)textField {
[pickerView reloadAllComponents];
// Make a new view, or do what you 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:@" a "];
[arryState addObject:@" b "];
[arryState addObject:@" c "];
[arryState addObject:@" d "];
[arryState addObject:@" e "];
[super viewDidLoad];
}
in my .m and
@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 my .h file
Now the text fields are not editable and I need some help or guidance, or any tutorial on how to connect UIPicker with multiple sources that can be change when text fields are editing
So i see no one cares :)
what i have now is 3 textFields and whenever i touch textField1 or textField2 Picker changes values and there is no keyboard. When i touch textField3 keyboard appears and the picker goes hidden.Now if i dismiss the keyboard by clicking return and then click textField1 picker appears again, but if i dont dismiss the keyboard BY CLICKING BUTTON it stays over the picker. What I need is when the keyboard is firstResponder (and i see it on the screen) to hide it if i click on the textField1 and only to see the picker