UIPickerView 中的 reloadComponent 方法
帮助文档中是这么说的:
调用此方法会导致选取器视图向委托查询给定组件的新数据。
我在以下位置添加了一些断点:
- (NSInteger)numberOfComponentsInPickerView:(UIPickerView *)pickerView
- (NSInteger)pickerView:(UIPickerView *)pickerView numberOfRowsInComponent:(NSInteger)component
- (NSString *)pickerView:(UIPickerView *)pickerView titleForRow:(NSInteger)row forComponent:(NSInteger)component
当我调用 reloadComponent
方法时,但没有一个断点被调用。问题是什么?
In the help document, it says that:
Calling this method causes the picker view to query the delegate for new data for the given component.
I added some breakpoints at:
- (NSInteger)numberOfComponentsInPickerView:(UIPickerView *)pickerView
- (NSInteger)pickerView:(UIPickerView *)pickerView numberOfRowsInComponent:(NSInteger)component
- (NSString *)pickerView:(UIPickerView *)pickerView titleForRow:(NSInteger)row forComponent:(NSInteger)component
when I call the reloadComponent
method but none of them were called. What is the problem?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您需要将 pickerView 的 dataSource 属性设置为实现 UIPickerViewDataSource 协议。
我认为文档指的是软件工程设计模式中的“委托”,而不是类的属性
delegate
,这可能有点误导。You need to set the
dataSource
property of the pickerView to an instance of a class that implements the UIPickerViewDataSource protocol.I think the documentation is referring to a "delegate" as in the software engineering design pattern of delegation, as opposed to the property
delegate
of the class which is probably a little misleading.