This commit is contained in:
lianxiang
2018-09-17 22:58:04 +08:00
parent 718900a428
commit 1a4b9db16f
22 changed files with 17646 additions and 32 deletions
@@ -130,7 +130,6 @@
}
- (void)checkNetwork{
AFNetworkReachabilityManager *manager = [AFNetworkReachabilityManager sharedManager];
[manager startMonitoring];
@@ -111,7 +111,9 @@
if ([selectedItem[@"childrens"] count] == 0) {
//此时为最后一列可能就一列或多列的最后一列
[self.showIndexs replaceObjectAtIndex:component withObject:@(row)];
}else{
NSUInteger replaceIdx = component;
@@ -122,10 +124,12 @@
}else{
if (replaceIdx < [self.showIndexs count]) {
NSArray *childrens = selectedItem[@"childrens"];
[self.showAddressArr replaceObjectAtIndex:replaceIdx withObject:selectedItem[@"childrens"]];
[self.showAddressArr replaceObjectAtIndex:replaceIdx withObject:childrens];
[self.showIndexs replaceObjectAtIndex:replaceIdx withObject:@(0)];
selectedItem = [selectedItem[@"childrens"] firstObject];
selectedItem = [childrens firstObject];
}else{
next = false;
}
@@ -133,8 +137,8 @@
replaceIdx ++;
}
}
[pickerView reloadAllComponents];
//实时更新选择数据及联数据
for (NSInteger index = 0; index < [self.showIndexs count]; index ++) {
@@ -155,7 +159,7 @@
NSString *jsonPath = [[NSBundle mainBundle] pathForResource:@"citys" ofType:@"json"];
NSData *data = [[NSData alloc] initWithContentsOfFile:jsonPath];
NSError *error = nil;
NSArray *citysArr = [NSJSONSerialization JSONObjectWithData:data options:kNilOptions error:&error];
NSArray *citysArr = [NSJSONSerialization JSONObjectWithData:data options:NSJSONReadingMutableContainers error:&error];
//初始化源数据
[self defaultShowValue:[NSMutableArray arrayWithArray:defaultValues] items:citysArr];
@@ -184,6 +188,7 @@
-(void)defaultShowValue:(NSMutableArray *)values items:(NSArray *)items
{
[items enumerateObjectsUsingBlock:^(NSDictionary *obj, NSUInteger idx, BOOL * _Nonnull stop) {
if ([@"" isEqualToString:[values firstObject]])
{
@@ -191,15 +196,20 @@
[self.showIndexs addObject:@(0)];
[values removeObjectAtIndex:0];
[self.showAddressArr addObject:items];
[self defaultShowValue:values items:obj[@"childrens"]];
NSArray *childs = obj[@"childrens"];
if (!childs) {
childs = @[];
}
[self defaultShowValue:values items:childs];
}
else if ([obj[@"text"] isEqualToString:[values firstObject]])
{
[self.showIndexs addObject:@(idx)];
[values removeObjectAtIndex:0];
[self.showAddressArr addObject:items];
[self defaultShowValue:values items:obj[@"childrens"]];
NSArray *childs = obj[@"childrens"];
[self defaultShowValue:values items:childs];
}
}];
}
File diff suppressed because it is too large Load Diff
+4 -2
View File
@@ -13985,7 +13985,8 @@
"value": "2929",
"text": "崇明县",
"childrens": []
},
},
{
"value": "290001",
"text": "黄浦区",
@@ -14060,7 +14061,8 @@
"value": "290015",
"text": "青浦区",
"childrens": []
},
},
{
"value": "290016",
"text": "南汇区",