Devang
Devang

Reputation: 11338

How can i use 2 picker view in my iPhone app?

I want to use two picker view in one xib. How can i do that ?

Upvotes: 1

Views: 2896

Answers (3)

Sukas
Sukas

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

dks1725
dks1725

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

Viktor Apoyan
Viktor Apoyan

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

Related Questions