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 轻松帮我们搞掂. <!--下拉刷新- ...
随机推荐
- Codeforces Round #318 (Div. 2) A Bear and Elections (优先队列模拟,水题)
优先队列模拟一下就好. #include<bits/stdc++.h> using namespace std; priority_queue<int>q; int main( ...
- caffe的pad的报错
CHECK((!conv_param.has_stride() && conv_param.has_stride_h() && conv_param.has_strid ...
- python_108_格式化字符串format函数
#通过关键字映射 print('I am {name},age {age}'.format(name='qiqi齐',age=18))#I am qiqi齐,age 18 dictory={'name ...
- Java MiniUi datagrid加载数据时,如果使用virtualScroll="false",数据多一点可能就会加载不出来
datagrid的值为 virtualScroll="true" 问题解决.
- Java调用存储过程出现Bug,sql语法错误
因为SQL Server运行没有正常,检查了传入参数的值,发现问题,然后传入默认参数,解决了问题.
- QT5:先导篇 全局定义
一.简介 <QtGlobal>头文件包含了Qt类库的一些全局定义,包含基本数据类型 函数和宏 二.全局变量定义 <QtGlobal>定义的数据类型: Qt数据类型 ...
- 电脑上文件的后缀名被隐藏,把一个文本文件改成.bat时,默认打开的还是文本。
1.打开文件夹,选择组织,点击“文件夹和搜索选项”,如图: 2.选择“查看”,找到“隐藏已知文件类型的扩展名”,不要勾选这一项,如图: 3.点击“确定”或者“应用”
- 实现类似AOP的封装和配置
这是张孝祥老师Java进阶讲解中最后一个视频,就是实现类似spring中的AOP的封装和配置,特别特别小型的一个框架雏形,但是spring中的核心思想还是体现出来了,真的厉害,张老师!!! 一.重点知 ...
- hihoCode-1043-完全背包
我们定义:best(i,x)代表i件以前的物品已经决定好选择多少件,并且在剩余奖券x的情况下的最优解. 我们可以考虑最后一步,是否再次选择i物品,在不超过持有奖券总额的情况下.上面的第二个式子的k是大 ...
- [LUOGU] P3128 [USACO15DEC]最大流Max Flow
题意:一棵树,多次给指定链上的节点加1,问最大节点权值 n个点,n-1条边很容易惯性想成一条链,幸好有样例.. 简单的树剖即可!(划去) 正常思路是树上差分,毕竟它就询问一次.. #include&l ...