Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/ios/121.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Ios 将所选值放入文本字段中_Ios_Uipickerview - Fatal编程技术网

Ios 将所选值放入文本字段中

Ios 将所选值放入文本字段中,ios,uipickerview,Ios,Uipickerview,当用户在pickerView中选择一个项目并按下OK按钮时,我必须将所选项目放入UITextField,因此在OK按钮的iAction中,我应该放入什么?thx预付款:) 这是我的确定按钮代码: -(IBAction)okButton{ [billTotal setText:@"Hi"];//the text field name is billTotal, this didn't work :( [UIView beginAnimations:nil context:nil]

当用户在pickerView中选择一个项目并按下OK按钮时,我必须将所选项目放入UITextField,因此在OK按钮的iAction中,我应该放入什么?thx预付款:) 这是我的确定按钮代码:

-(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];  
}
大概是这样的:

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


检查您的出口是否连接到文本字段,并且调用了“OK Button”选择器

如果您想放置选定行的值,即行的标题,您应该从数组中接收此标题,或者您使用什么来存储它们,通过选择Low indexHi,thx作为您的答案,我尝试实现您的代码,我选择的每个项在UITextField中都显示为0,就像它不传输选择器的整个值一样:(数组名称为pickerViewArray@Malek,请检查您的选取器出口是否已连接到UIPickerView,否则您将始终收到0。若要从阵列接收您的项目,请使用[PickerWebArray对象索引:selectedRow];@Malek,你检查过插座连接了吗?