Reputation: 11338
I want to use two picker view in one xib. How can i do that ?
Upvotes: 1
Views: 2896
Reputation: 267
You can use single PickerView for two operations- Pass Array Values with Tag Values
for First Operation :
self.pickerView = [[NSMutableArray alloc]initWithObjects:@"France", @"Italy", @"California", @"", nil];
self.pickerView.tag = 111;
For second operation:
self.pickerView = [[NSMutableArray alloc]initWithObjects:your array values, @"",nil];
self.pickerView.tag = 222;
Then in
-(void)pickerView:(UIPickerView *)pView didSelectRow:(NSInteger)row inComponent: (NSInteger)component
{
if (self.pickerView.tag == 111) {
NSLog(@"First Picker View selected Value")
}
else if(self.pickerView.tag == 222){
NSLog(@"Second Picker View Selected Value")
}
}
Upvotes: 2
Reputation: 1631
When you want to load pv1 then call
[pv1 reloadAllComponents];
and when you want to load pv2 then call
[pv2 reloadAllComponents];
Upvotes: 0
Reputation: 10755
You can add two UIPickerView
and create two properties for them like bellow
@property (nonatomic, retain) IBOutlet UIPickerView* pv1;
@property (nonatomic, retain) IBOutlet UIPickerView* pv2;
and then work with them.
Upvotes: 1