UIPicker不会设置文本字段
问题描述:
我有一个自定义选择器与国家名单和相应的标志一切工作正常,但我想当国家被选中国家名称和国旗作为背景图片来显示,我不明白为什么我的方法不能将文本设置为文本,对我来说没有任何意义。 这是我的代码:请注意我的“国家”NSSTring已在接口中正确声明并在.m 和namefieldText IBOutlet已连接中合成。 代码:UIPicker不会设置文本字段
- (void)pickerView:(UIPickerView *)pickerView didSelectRow:(NSInteger)row inComponent:(NSInteger)component
{
// report the selection to the UI label
country = [customPickerArray objectAtIndex:[pickerView selectedRowInComponent:0]];
nameFiled.text =country; // Nothing happens here
NSLog(@"%@",country); //NSLog show correctly selected country in a console
}
答
的问题是与你:
国家= [customPickerArray objectAtIndex:[pickerView selectedRowInComponent:0];
相反,你应该说:
国家= [customPickerArray objectAtIndex:行]。
祝你好运!