主要代码:处理在滑动每一列时数据的操作。
/**
* pickerView选中代理
* @param row 选中的row
* @param component 列
*/
- (void)pickerView:(UIPickerView *)pickerView didSelectRow:(NSInteger)row inComponent:(NSInteger)component{
if(component==0)
{
self.selectRow0 = row;
self.selectRow1 = 0;
self.selectRow2 = 0;
self.provinceArray = (NSMutableArray <DHAreasProvinceModel *> *)self.areasModel.content;
self.cityArray = (NSMutableArray <DHAreasCityModel*>*)self.provinceArray[row].childList;
self.countryArray = (NSMutableArray<DHAreasCountryModel*>*)self.cityArray[0].childList;
[pickerView reloadComponent:1];
[pickerView selectRow:0 inComponent:1 animated:YES];//默认选择row 0
[pickerView reloadComponent:2];
[pickerView selectRow:0 inComponent:2 animated:YES];
}
if(component==1)
{
self.selectRow1 = row;
self.selectRow2 = 0;
self.countryArray = (NSMutableArray<DHAreasCountryModel*>*)self.cityArray[row].childList;
[pickerView reloadComponent:2];
[pickerView selectRow:0 inComponent:2 animated:YES];
}
if(component==2){
self.selectRow2 = row;
}
}
屏幕快照 2018-07-10 上午9.42.17.png
网友评论