Search code examples
iphoneobjective-ccocoa-touchios4uipickerview

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 ?


Solution

  • 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")
        }
    
    }