iOS控件-3级城市列表-plist版
@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);
}
效果图:
iOS控件-3级城市列表-plist版的更多相关文章
- 设计一个 iOS 控件
转载自:http://blog.csdn.net/zhangao0086/article/details/45622875 代码的等级:可编译.可运行.可测试.可读.可维护.可复用 前言 一个控件从外 ...
- iOS控件之UIResponder类
iOS控件之UIResponder类 在iOS中UIResponder类是专门用来响应用户的操作处理各种事件的,我们知道UIApplication.UIView.UIViewController这几个 ...
- iOS控件——UIView的viewWithTag:(int)findTag方法描述
UIView拥有一个viewWithTag:(int)findTag方法,调用方式为[MyView viewWithTag:整形数字]该方法返回tag == findTag的控件.ios控件中允许多个 ...
- ios学习笔记图片+图片解释(c语言 oc语言 ios控件 ios小项目 ios小功能 swift都有而且笔记完整喔)
下面是目录其中ios文件夹包括了大部分ios控件的介绍和演示,swift的时完整版,可以学习完swift(这个看的是swift刚出来一周的视频截图,可能有点赶,但是完整),c语言和oc语言的也可以完整 ...
- [iOS基础控件 - 4.2] APP列表 字典转模型Model
A.使用字典加载数据的缺点 1.用户自行指定key,容易出错 2.存入.取出都需要key,容易混乱 B.模型 (MVC中的model) 1.字典与模型对比: (1)字典:存储数据,通过字符串类型的 ...
- 如何设计一个 iOS 控件?(iOS 控件完全解析) (转)
前言 一个控件从外在特征来说,主要是封装这几点: 交互方式 显示样式 数据使用 对外在特征的封装,能让我们在多种环境下达到 PM 对产品的要求,并且提到代码复用率,使维护工作保持在一个相对较小的范围内 ...
- 如何设计一个 iOS 控件?(iOS 控件完全解析)
前言 一个控件从外在特征来说,主要是封装这几点: 交互方式 显示样式 数据使用 对外在特征的封装,能让我们在多种环境下达到 PM 对产品的要求,并且提到代码复用率,使维护工作保持在一个相对较小的范围内 ...
- IOS控件大全及控件大小
一 视图UIView和UIWindow iphone视图的规则是:一个窗口,多个视图.UIWindow相当于电视机,UIViews相当于演员. 1.显示数据的视图 下面几个类可在屏幕上显示信息: UI ...
- ionic 2 起航 控件的使用 客户列表场景(四)
接下来,我们的客户列表要怎么刷新数据呢? 我们不会安卓开发,不会ios开发,没关系,我们还有ionic 2.ionic 2的控件 Ion-refresher 轻松帮我们搞掂. <!--下拉刷新- ...
随机推荐
- SqlServer表和excel数据批量复制方法
SqlServer表和excel数据批量复制方法 一.SqlServer表数据复制到excel方法: 1.新建查询,用sql语句把表数据读出来 2.然后,选择数据,右键“复制”(如果需要表字段名称,则 ...
- robotframework接口测试实例
*** Settings *** Library Collections Library RequestsLibrary *** Test Cases *** test Create Session ...
- C03 程序逻辑
程序逻辑 运算符 顺序结构 选择结构 循环结构 运算符 赋值运算符:= 比较运算符:>.<.==. >=.<=.!= 逻辑运算符:&&.||.! 顺序结构 在C ...
- ios软件设计中注意点
1.取消系统自带渲染效果 2.取消屏幕旋转 3.项目中搜索丢失文件
- React项目搭建及依赖安装
一.前提 首先保证node.js已安装完成... 安装完成后,打开cmd命令行,输入 node -v 和 npm -v 来查看版本号,如果显示则安装完成. 二.安装react脚手架 在cmd命令行中输 ...
- vue+axios+promise实际开发用法
axios它是基于promise的http库,可运行在浏览器端和node.js中,然后作者尤雨溪也是果断放弃了对其官方库vue-resource的维护,直接推荐axios库,小编我也是从vue-res ...
- CSS3的渐变-gradient
CSS3 Gradient分为linear-gradient(线性渐变)和radial-gradient(径向渐变). CSS3的线性渐变 一.线性渐变在Mozilla下的应用 语法: -moz-li ...
- CSS盒模型-box-sizing
CSS中Box model是分为两种,第一种是W3C的标准模型,另一种是IE的传统模型 1.W3C的标准Box Model: /*外盒尺寸计算(元素空间尺寸)*/ Element空间高度 = cont ...
- python基础知识13-迭代器与生成器,导入模块
异常处理作业讲解 file = open('/home/pyvip/aaa.txt','w+') try: my_dict = {'name':'adb'} file.write(my_dict['a ...
- 二、Pandas库与数据处理
# Author:Zhang Yuan import pandas as pd import numpy as np #Pandas提供了两大数据结构:一维结构的Series类型.二维结构的DataF ...