gpt4 book ai didi

ios - UIPickerview 没有调用 titleForRow

转载 作者:行者123 更新时间:2023-12-01 16:40:44 27 4
gpt4 key购买 nike

我有一个 uipickerview,我试图用 coredata 数据库中的博士列表填充它。我正在 viewdidload 中加载博士列表,并通过 nslog 语句验证了它们的存在。在验证它们在那里之后,我执行了 reloadallcomponents 并且我的pickerview 显示了适当数量的“?”分数。当我设置断点时,我注意到我的应用程序通过两次获取行数,并返回适当的数字,但 titleforrow 方法从未被调用。有什么想法吗?

- (NSInteger)numberOfComponentsInPickerView:
(UIPickerView *)pickerView
{
return 1;
}

- (NSInteger)pickerView:(UIPickerView *)pickerView
numberOfRowsInComponent:(NSInteger)component
{
NSLog(@"there are %d doctors",[self.doctors count]);
return [self.doctors count];
}

- (NSString *)pickerView:(UIPickerView *)pickerView titleForRow:(NSInteger)row forComponent:(NSInteger)component
{
NSLog(@"Row %d has dr %@",row,[self.doctors objectAtIndex:row]);
return [self.doctors objectAtIndex:row];
}

最佳答案

您必须将 pickerView.dataSource = ... 设置为您的 Controller ;

关于ios - UIPickerview 没有调用 titleForRow,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24708428/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com