@import url(http://i.cnblogs.com/Load.ashx?type=style&file=SyntaxHighlighter.css);@import url(/css/cuteeditor.css);

plist部分:

调用部分:

- (void)textFieldDidBeginEditing:(UITextField *)textField {
WJCityPikerView *piker = [[WJCityPikerView alloc]initWithModelBlock:^(WJPikerDataModel *model) {
NSLog(@"%@ %@ %@ %@ %@ %@",model.provinceName,model.cityName,model.disName,model.provinceId,model.cityId,model.disId);
[self.view endEditing:YES];
} backBlock:^{
NSLog(@"返回");
[self.view endEditing:YES];
}];
textField.inputView = piker;
}

内部:

1.取出plist中的信息

//总数据
- (NSArray *)dataArray {
if (!_dataArray) {
NSBundle *bundle = [NSBundle mainBundle];
NSString *plistPath = [bundle pathForResource:@"city" ofType:@"plist"];
_dataArray = [[NSArray alloc]initWithContentsOfFile:plistPath];
}
return _dataArray;
}

2.创建省,市,区三个数组分别装查找到的省市区的信息

@property (nonatomic,strong)NSMutableArray *provenceArray;
@property (nonatomic,strong)NSMutableArray *cityArray;
@property (nonatomic,strong)NSMutableArray *areaArray;

3.滚动滚轮在数组里面查找省市区的信息并将他们添加到相应的数组中

- (void)pickerView:(UIPickerView *)pickerView didSelectRow:(NSInteger)row inComponent:(NSInteger)component {
switch (component) {
case :
{
WJCityPlist *plist2 = self.provenceArray[row];
self.cityArray = [[NSMutableArray alloc]init];
[self.dataArray enumerateObjectsUsingBlock:^(NSDictionary *dic, NSUInteger idx, BOOL * _Nonnull stop) {
if ([dic[@"pid"]integerValue] == [plist2.Id integerValue]) {
WJCityPlist *plist = [[WJCityPlist alloc]initWithDic:dic];
[self.cityArray addObject:plist];
}
}];
WJCityPlist *plist3 = self.cityArray[];
self.areaArray = [[NSMutableArray alloc]init];
[self.dataArray enumerateObjectsUsingBlock:^(NSDictionary *dic, NSUInteger idx, BOOL * _Nonnull stop) {
if ([dic[@"pid"]integerValue] == [plist3.Id integerValue]) {
WJCityPlist *plist = [[WJCityPlist alloc]initWithDic:dic];
[self.areaArray addObject:plist];
}
}];
[_piker selectRow: inComponent: animated:NO];
[_piker reloadAllComponents];
[_piker reloadComponent:];
[_piker reloadComponent:];
_indexprovence = row;
break;
}
case :
{
WJCityPlist *plist3 = self.cityArray[row];
self.areaArray = [[NSMutableArray alloc]init];
[self.dataArray enumerateObjectsUsingBlock:^(NSDictionary *dic, NSUInteger idx, BOOL * _Nonnull stop) {
if ([dic[@"pid"]integerValue] == [plist3.Id integerValue]) {
WJCityPlist *plist = [[WJCityPlist alloc]initWithDic:dic];
[self.areaArray addObject:plist];
}
}];
[_piker selectRow: inComponent: animated:NO];
[_piker reloadComponent:];
_indexcity = row;
}
break;
case :
_indexaera = row;
break;
default:
break;
}
NSLog(@"%ld %ld %ld",_indexprovence,_indexcity,_indexaera);
}

效果图:

最新文章

  1. Couchbase N1QL
  2. 第22章 DLL注入和API拦截(1)
  3. PHP使用DateTime类做时间日期到字符串转换
  4. 打开开源项目总得.md文件
  5. bzoj 2141 线段树套平衡树
  6. HTML5-Video & Audio
  7. 【原创】海量数据处理问题(一) ---- 外排,堆排,K查找的应用
  8. CentOS安装mplayer
  9. bootstrap-datetimepicker 时间表箭头不能显示
  10. system2之:4-文件系统管理(上)
  11. 使用MiniProfiler调试Asp.net Mvc性能
  12. keepalive的 nopreempt 非抢占
  13. 2015最新iOS学习线路图
  14. tablesorter 的使用
  15. DB 查询分析器 6.03 ,遨游于任何Windows操作系统之上的最优秀的数据库客户端工具
  16. Springboot 系列(三)Spring Boot 自动配置原理
  17. MT【316】常数变易法
  18. 语音识别传统方法(GMM+HMM+NGRAM)概述
  19. Android源码分析一 Android系统架构
  20. boost::bind 实现原理, 手动实现一个

热门文章

  1. you don't have permission to access / on this server解决
  2. C# DataTable的詳細用法 (转)
  3. (十一)mybatis之映射器(select)
  4. Invalid bound statement (not found): com.ros.dao.LogMapper.insert
  5. Python学习日志9月15日
  6. 数据库_7_SQL基本操作——表操作
  7. 计算机图形学:贝塞尔曲线(Bezier Curve)
  8. gson对象的相互转换
  9. ios设备屏幕尺寸与分辨率
  10. NSLayoutConstraint.constraintsWithVisualFormat详解,以及AlignAllCenterY