项目介绍:
一个非常方便使用的省市区域地址选择器
主要显示代码如下:
[Objective-C] 查看源文件 复制代码
- (void)show:(UIButton *)sender { NSString *address = _addressLabel.text; NSArray *array = [address componentsSeparatedByString:@" "]; NSString *province = @"";//省 NSString *city = @"";//市 NSString *county = @"";//县 if (array.count > 2) { province = array[0]; city = array[1]; county = array[2]; } else if (array.count > 1) { province = array[0]; city = array[1]; } else if (array.count > 0) { province = array[0]; } [self.regionPickerView showPickerWithProvinceName:province cityName:city countyName:county]; } - (HXProvincialCitiesCountiesPickerview *)regionPickerView { if (!_regionPickerView) { _regionPickerView = [[HXProvincialCitiesCountiesPickerview alloc] initWithFrame:CGRectMake(0, 0, self.view.frame.size.width, self.view.frame.size.height)]; __weak typeof(self) wself = self; _regionPickerView.completion = ^(NSString *provinceName,NSString *cityName,NSString *countyName) { __strong typeof(wself) self = wself; self.addressLabel.text = [NSString stringWithFormat:@"%@ %@ %@",provinceName,cityName,countyName]; }; [self.navigationController.view addSubview:_regionPickerView]; } return _regionPickerView; }
DEMO直接下载: