将所选值放在文本字段中

时间:2011-04-15 15:35:10

标签: ios uipickerview

当用户在pickerView中选择一个项目并按下OK按钮时,我必须将所选项目放在UITextField中,所以在OK按钮的IBAction中我该放什么? thx提前:) 这是我的OK按钮代码:

-(IBAction)okButton{
    [billTotal setText:@"Hi"];//the text field name is billTotal, this didn't work :(

    [UIView beginAnimations:nil context:nil];
    [UIView setAnimationDuration:0.5];
    CGAffineTransform transform = CGAffineTransformMakeTranslation(0, 480);
    pickerView.transform = transform;
    [UIView commitAnimations];  
}

1 个答案:

答案 0 :(得分:1)

这样的事情:

...
NSInteger selectedRow = [picker selectedRowInComponent:0];
billTotal.text = [NSString stringWithFormat:@"%d", selectedRow];
...
  

这不起作用

检查您的插座是否连接到文本字段,并且调用“okButton”选择器