【发布时间】:2012-06-27 09:46:20
【问题描述】:
我有一个 mainViewController 和一个 UIPickerView。现在一切都设置好了,但是当我运行应用程序并选择 textField 时,我的 UIPickerView 列表中出现了问号。
现在我才知道,那是因为我没有为它连接代理。 但是,如果我为它连接代理,则不会填充 textField。
TextField 在 mainViewController 中。
所以在我的 MainViewController.h 中,我已经导入了 UIPickerView 并拥有这段代码 - 这一切都没有错误。 _pv 是 UIPickerView。
_pv = [[CategoryPicker alloc] init];
[_pv.categoryPicker setDelegate:self];
[_pv.categoryPicker setDataSource:_pv];
[_appPriorityTxtFld setInputView:_pv];
[_appPriorityTxtFld setInputAccessoryView:toolbar];
现在您可以看到 Delegate 设置为 self,这将允许填充 textField。
如果我将其设置为 _pv,那么我会正确显示列表,但不会填充 textField。
我错过了什么??
干杯
【问题讨论】:
-
你实现
pickerView:didSelectRow:inComponent:了吗?您应该在该方法中更新文本字段的文本。 -
在 UIPickerView 中?所以我需要反过来导入它?
-
但是我已经实现了 - 这就是我在 textField 中得到结果的原因。
标签: objective-c ios delegates datasource uipickerview