如何将pickerview的值与textview结合起来?

时间:2009-10-29 08:58:35

标签: iphone

在我的应用程序中按下提交按钮我想执行提交操作,但我不知道如何将textview的值与pickerview的值结合起来。如果有可能,那么请用示例向我展示代码。

1 个答案:

答案 0 :(得分:0)

您希望如何将这些值组合成一个字符串?

如果您只想将它​​们组合在一个字符串中,下面是一个如何实现它的示例:

- (IBAction)submitPressed:(id)sender {
    // Load the selected row for the first component in your picker view
    // If you have more than one component you may need to look up more
    // Also, you may need to translate this number into something more meaningful
    // such as what the selected row represents
    int selectedRow = [pickerView selectedRowInComponent:0];
    NSString *myString = [NSString stringWithFormat:@"%@ %d", 
        textView.text, selectedRow];
    // Do something with myString...
}