(1) 在数据模型中写一个 过滤方法
(2) 刷新列表
- (NSString *)cityNameWithIndex: (NSInteger)index
{
// 判断索引是否越界
if (index < self.cities.count) {
return self.cities[index];
}else{
return nil;
}
}(2) 刷新列表
- (void)pickerView:(UIPickerView *)pickerView didSelectRow:(NSInteger)row inComponent:(NSInteger)component {
// 只有第0列变化需要刷新第1列的内容
if (component == 0)
{
[pickerView reloadComponent:1];
}
// 1> 第0列选中
int pRow = [pickerView selectedRowInComponent:0];
// 2> 第1列选中
int cRow = [pickerView selectedRowInComponent:1];
NSString *cityName = [self.provinces[pRow] cityNameWithIndex:cRow];
self.cityLabel.text = cityName;
}
本文将介绍如何在iOS应用中利用Objective-C和Swift实现选择器与列表的刷新功能,包括如何通过下拉刷新列表并获取城市名称,以及在不同列之间的数据交互。
2393

被折叠的 条评论
为什么被折叠?



