iPhone:多个UIPickerView

时间:2011-04-30 09:03:12

标签: objective-c uitextfield uipickerview

我在iPhone应用程序中使用多个UIPickerView。我的问题是,如何处理多个UIPickerView句柄事件?

另外,我想将所选值放在UITextField的{​​{1}}中。

2 个答案:

答案 0 :(得分:11)

答案 1 :(得分:1)

- (NSInteger)pickerView:(UIPickerView *)pickerView numberOfRowsInComponent:(NSInteger)component{
    NSInteger counter;
    if(pickerView==p1)
    {
        counter=[name count];
    }
    else
    {
        counter=[name2 count];
    }
    return counter;

}
- (NSString *)pickerView:(UIPickerView *)pickerView titleForRow:(NSInteger)row forComponent:(NSInteger)component{
    if(pickerView==p1)
        return [name objectAtIndex:row];//name is NsMutable Array
    else
        return [name2 objectAtIndex:row];//name2 is NsMutable Array

}