2012-04-25 6 views
0

私はメートル、センチメートル、ミリメートルの3つのコンポーネントを持つUIPickerViewを持っており、そのような選択されたセルを変更できるようにしたい。UIPickerViewの選択したセルを変更するには?

say私が選択すると、m、cm、mmに対して10,20,5です。

これらのユニットは、選択したセルの数字のほかに、10m 20cm 5mmと表示する必要があります。

どうすればよいですか?

答えて

0

これが最善の解決策になるが、私は私のクラス変数としてlastSelectedRowとlastSelectedComponentを持っている...

ここ
- (void)pickerView:(UIPickerView *)pickerView didSelectRow:(NSInteger)row inComponent:  (NSInteger)component 
{ 
    UILabel *tempView1 = (UILabel *)[pickerView viewForRow:lastSelectedRow forComponent:lastSelectedComponent]; 
    tView1.text = [NSString stringWithFormat:@" %@",[yourDataArray objectAtIndex:lastSelectedRow]]; 

    UILabel *tView = (UILabel *)[pickerView viewForRow:row forComponent:component]; 
    tView.text = [NSString stringWithFormat:@" %@ cm",[yourDataArray objectAtIndex:row]]; 
    lastSelectedRow = row; 
    lastSelectedComponent = component; 

} 

を動作しているようだしない場合があります。

+0

それは私の心の中で唯一のものでした。私は他の方法があるに違いないと思ったが、とにかく感謝している。 –

関連する問題