地址选择修改

This commit is contained in:
lianxiang 2018-09-18 01:08:31 +08:00
parent 1a4b9db16f
commit 2c81fa6c7d
6 changed files with 22 additions and 31689 deletions

View File

@ -23,7 +23,8 @@
8338F6B12142182200B4780B /* MaskTime.png in Resources */ = {isa = PBXBuildFile; fileRef = 8338F6B02142182100B4780B /* MaskTime.png */; }; 8338F6B12142182200B4780B /* MaskTime.png in Resources */ = {isa = PBXBuildFile; fileRef = 8338F6B02142182100B4780B /* MaskTime.png */; };
8338F6B92142504E00B4780B /* LXCustomSwith.m in Sources */ = {isa = PBXBuildFile; fileRef = 8338F6B82142504E00B4780B /* LXCustomSwith.m */; }; 8338F6B92142504E00B4780B /* LXCustomSwith.m in Sources */ = {isa = PBXBuildFile; fileRef = 8338F6B82142504E00B4780B /* LXCustomSwith.m */; };
833DA7762122A62000A5C614 /* GiGaMaskTaskViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 833DA7752122A62000A5C614 /* GiGaMaskTaskViewController.m */; }; 833DA7762122A62000A5C614 /* GiGaMaskTaskViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 833DA7752122A62000A5C614 /* GiGaMaskTaskViewController.m */; };
833DE8D7214FF7F8009D4329 /* city1.js in Resources */ = {isa = PBXBuildFile; fileRef = 833DE8D6214FF7F8009D4329 /* city1.js */; }; 833DE8E42150169F009D4329 /* city.json in Resources */ = {isa = PBXBuildFile; fileRef = 833DE8E22150169F009D4329 /* city.json */; };
833DE8E52150169F009D4329 /* JYAddressPicker.m in Sources */ = {isa = PBXBuildFile; fileRef = 833DE8E32150169F009D4329 /* JYAddressPicker.m */; };
8340BF9E213E3846008F22E4 /* SHineLabel.m in Sources */ = {isa = PBXBuildFile; fileRef = 8340BF9D213E3846008F22E4 /* SHineLabel.m */; }; 8340BF9E213E3846008F22E4 /* SHineLabel.m in Sources */ = {isa = PBXBuildFile; fileRef = 8340BF9D213E3846008F22E4 /* SHineLabel.m */; };
8340BFA2213E60DD008F22E4 /* GIGAMBHUDHelper.m in Sources */ = {isa = PBXBuildFile; fileRef = 8340BFA1213E60DD008F22E4 /* GIGAMBHUDHelper.m */; }; 8340BFA2213E60DD008F22E4 /* GIGAMBHUDHelper.m in Sources */ = {isa = PBXBuildFile; fileRef = 8340BFA1213E60DD008F22E4 /* GIGAMBHUDHelper.m */; };
8340BFA6213E6514008F22E4 /* Localizable.strings in Resources */ = {isa = PBXBuildFile; fileRef = 8340BFA5213E6514008F22E4 /* Localizable.strings */; }; 8340BFA6213E6514008F22E4 /* Localizable.strings in Resources */ = {isa = PBXBuildFile; fileRef = 8340BFA5213E6514008F22E4 /* Localizable.strings */; };
@ -126,8 +127,6 @@
83901179214E20B2004CA790 /* LYSDatePickerTypeBase.m in Sources */ = {isa = PBXBuildFile; fileRef = 83901162214E20B1004CA790 /* LYSDatePickerTypeBase.m */; }; 83901179214E20B2004CA790 /* LYSDatePickerTypeBase.m in Sources */ = {isa = PBXBuildFile; fileRef = 83901162214E20B1004CA790 /* LYSDatePickerTypeBase.m */; };
8390117A214E20B2004CA790 /* LYSDatePickerController.m in Sources */ = {isa = PBXBuildFile; fileRef = 83901164214E20B1004CA790 /* LYSDatePickerController.m */; }; 8390117A214E20B2004CA790 /* LYSDatePickerController.m in Sources */ = {isa = PBXBuildFile; fileRef = 83901164214E20B1004CA790 /* LYSDatePickerController.m */; };
8390117B214E20B2004CA790 /* LYSDatePickerHeaderView.m in Sources */ = {isa = PBXBuildFile; fileRef = 83901165214E20B1004CA790 /* LYSDatePickerHeaderView.m */; }; 8390117B214E20B2004CA790 /* LYSDatePickerHeaderView.m in Sources */ = {isa = PBXBuildFile; fileRef = 83901165214E20B1004CA790 /* LYSDatePickerHeaderView.m */; };
8390117C214E20B2004CA790 /* citys.json in Resources */ = {isa = PBXBuildFile; fileRef = 83901169214E20B2004CA790 /* citys.json */; };
8390117D214E20B2004CA790 /* JYAddressPicker.m in Sources */ = {isa = PBXBuildFile; fileRef = 8390116A214E20B2004CA790 /* JYAddressPicker.m */; };
83928FFA2134D8F60077D2E8 /* GiGaFlyingCommitInputView.m in Sources */ = {isa = PBXBuildFile; fileRef = 83928FF92134D8F60077D2E8 /* GiGaFlyingCommitInputView.m */; }; 83928FFA2134D8F60077D2E8 /* GiGaFlyingCommitInputView.m in Sources */ = {isa = PBXBuildFile; fileRef = 83928FF92134D8F60077D2E8 /* GiGaFlyingCommitInputView.m */; };
83928FFE2134F37D0077D2E8 /* GiGaSocketRocketUtility.m in Sources */ = {isa = PBXBuildFile; fileRef = 83928FFD2134F37D0077D2E8 /* GiGaSocketRocketUtility.m */; }; 83928FFE2134F37D0077D2E8 /* GiGaSocketRocketUtility.m in Sources */ = {isa = PBXBuildFile; fileRef = 83928FFD2134F37D0077D2E8 /* GiGaSocketRocketUtility.m */; };
839290052134F4240077D2E8 /* LXDanMuTrackView.m in Sources */ = {isa = PBXBuildFile; fileRef = 839290002134F4230077D2E8 /* LXDanMuTrackView.m */; }; 839290052134F4240077D2E8 /* LXDanMuTrackView.m in Sources */ = {isa = PBXBuildFile; fileRef = 839290002134F4230077D2E8 /* LXDanMuTrackView.m */; };
@ -203,7 +202,9 @@
8338F6B82142504E00B4780B /* LXCustomSwith.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = LXCustomSwith.m; sourceTree = "<group>"; }; 8338F6B82142504E00B4780B /* LXCustomSwith.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = LXCustomSwith.m; sourceTree = "<group>"; };
833DA7742122A62000A5C614 /* GiGaMaskTaskViewController.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = GiGaMaskTaskViewController.h; sourceTree = "<group>"; }; 833DA7742122A62000A5C614 /* GiGaMaskTaskViewController.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = GiGaMaskTaskViewController.h; sourceTree = "<group>"; };
833DA7752122A62000A5C614 /* GiGaMaskTaskViewController.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = GiGaMaskTaskViewController.m; sourceTree = "<group>"; }; 833DA7752122A62000A5C614 /* GiGaMaskTaskViewController.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = GiGaMaskTaskViewController.m; sourceTree = "<group>"; };
833DE8D6214FF7F8009D4329 /* city1.js */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.javascript; path = city1.js; sourceTree = "<group>"; }; 833DE8E12150169F009D4329 /* JYAddressPicker.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = JYAddressPicker.h; sourceTree = "<group>"; };
833DE8E22150169F009D4329 /* city.json */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.json; path = city.json; sourceTree = "<group>"; };
833DE8E32150169F009D4329 /* JYAddressPicker.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = JYAddressPicker.m; sourceTree = "<group>"; };
8340BF9C213E3846008F22E4 /* SHineLabel.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = SHineLabel.h; sourceTree = "<group>"; }; 8340BF9C213E3846008F22E4 /* SHineLabel.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = SHineLabel.h; sourceTree = "<group>"; };
8340BF9D213E3846008F22E4 /* SHineLabel.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = SHineLabel.m; sourceTree = "<group>"; }; 8340BF9D213E3846008F22E4 /* SHineLabel.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = SHineLabel.m; sourceTree = "<group>"; };
8340BFA0213E60DD008F22E4 /* GIGAMBHUDHelper.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = GIGAMBHUDHelper.h; sourceTree = "<group>"; }; 8340BFA0213E60DD008F22E4 /* GIGAMBHUDHelper.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = GIGAMBHUDHelper.h; sourceTree = "<group>"; };
@ -390,9 +391,6 @@
83901164214E20B1004CA790 /* LYSDatePickerController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = LYSDatePickerController.m; sourceTree = "<group>"; }; 83901164214E20B1004CA790 /* LYSDatePickerController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = LYSDatePickerController.m; sourceTree = "<group>"; };
83901165214E20B1004CA790 /* LYSDatePickerHeaderView.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = LYSDatePickerHeaderView.m; sourceTree = "<group>"; }; 83901165214E20B1004CA790 /* LYSDatePickerHeaderView.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = LYSDatePickerHeaderView.m; sourceTree = "<group>"; };
83901166214E20B1004CA790 /* LYSDateLogicViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = LYSDateLogicViewController.h; sourceTree = "<group>"; }; 83901166214E20B1004CA790 /* LYSDateLogicViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = LYSDateLogicViewController.h; sourceTree = "<group>"; };
83901168214E20B2004CA790 /* JYAddressPicker.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = JYAddressPicker.h; sourceTree = "<group>"; };
83901169214E20B2004CA790 /* citys.json */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.json; path = citys.json; sourceTree = "<group>"; };
8390116A214E20B2004CA790 /* JYAddressPicker.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = JYAddressPicker.m; sourceTree = "<group>"; };
83928FF82134D8F60077D2E8 /* GiGaFlyingCommitInputView.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = GiGaFlyingCommitInputView.h; sourceTree = "<group>"; }; 83928FF82134D8F60077D2E8 /* GiGaFlyingCommitInputView.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = GiGaFlyingCommitInputView.h; sourceTree = "<group>"; };
83928FF92134D8F60077D2E8 /* GiGaFlyingCommitInputView.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = GiGaFlyingCommitInputView.m; sourceTree = "<group>"; }; 83928FF92134D8F60077D2E8 /* GiGaFlyingCommitInputView.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = GiGaFlyingCommitInputView.m; sourceTree = "<group>"; };
83928FFC2134F37D0077D2E8 /* GiGaSocketRocketUtility.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = GiGaSocketRocketUtility.h; sourceTree = "<group>"; }; 83928FFC2134F37D0077D2E8 /* GiGaSocketRocketUtility.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = GiGaSocketRocketUtility.h; sourceTree = "<group>"; };
@ -518,6 +516,17 @@
path = CustomSwitch; path = CustomSwitch;
sourceTree = "<group>"; sourceTree = "<group>";
}; };
833DE8E02150169F009D4329 /* JYAddressPicker */ = {
isa = PBXGroup;
children = (
833DE8E12150169F009D4329 /* JYAddressPicker.h */,
833DE8E22150169F009D4329 /* city.json */,
833DE8E32150169F009D4329 /* JYAddressPicker.m */,
);
name = JYAddressPicker;
path = ../../../../JYAddressPicker;
sourceTree = "<group>";
};
8340BF9F213E6080008F22E4 /* GIGAMBHUDHelper */ = { 8340BF9F213E6080008F22E4 /* GIGAMBHUDHelper */ = {
isa = PBXGroup; isa = PBXGroup;
children = ( children = (
@ -540,7 +549,7 @@
8340BFAC213E7374008F22E4 /* Views */ = { 8340BFAC213E7374008F22E4 /* Views */ = {
isa = PBXGroup; isa = PBXGroup;
children = ( children = (
83901167214E20B2004CA790 /* JYAddressPicker */, 833DE8E02150169F009D4329 /* JYAddressPicker */,
83901143214E20B1004CA790 /* LYSDatePickerController */, 83901143214E20B1004CA790 /* LYSDatePickerController */,
8338F6B62142504E00B4780B /* CustomSwitch */, 8338F6B62142504E00B4780B /* CustomSwitch */,
8340BFAD213E739D008F22E4 /* GiGaNoNetWorkView.h */, 8340BFAD213E739D008F22E4 /* GiGaNoNetWorkView.h */,
@ -1116,17 +1125,6 @@
path = LYSDatePickerController; path = LYSDatePickerController;
sourceTree = "<group>"; sourceTree = "<group>";
}; };
83901167214E20B2004CA790 /* JYAddressPicker */ = {
isa = PBXGroup;
children = (
833DE8D6214FF7F8009D4329 /* city1.js */,
83901168214E20B2004CA790 /* JYAddressPicker.h */,
83901169214E20B2004CA790 /* citys.json */,
8390116A214E20B2004CA790 /* JYAddressPicker.m */,
);
path = JYAddressPicker;
sourceTree = "<group>";
};
83928FFB2134F37D0077D2E8 /* SocketRocketUtility */ = { 83928FFB2134F37D0077D2E8 /* SocketRocketUtility */ = {
isa = PBXGroup; isa = PBXGroup;
children = ( children = (
@ -1345,6 +1343,7 @@
isa = PBXResourcesBuildPhase; isa = PBXResourcesBuildPhase;
buildActionMask = 2147483647; buildActionMask = 2147483647;
files = ( files = (
833DE8E42150169F009D4329 /* city.json in Resources */,
83346AC6212BBC8C0054D597 /* GiGaRegistViewController.xib in Resources */, 83346AC6212BBC8C0054D597 /* GiGaRegistViewController.xib in Resources */,
838762DE214B9F140039D241 /* GIGaUserWeChatViewCell.xib in Resources */, 838762DE214B9F140039D241 /* GIGaUserWeChatViewCell.xib in Resources */,
83BFAE6D213CD0E3004EF801 /* GiGaMineInfoViewCell.xib in Resources */, 83BFAE6D213CD0E3004EF801 /* GiGaMineInfoViewCell.xib in Resources */,
@ -1356,13 +1355,11 @@
838388C4212F934400D14C53 /* pomodoSound.m4a in Resources */, 838388C4212F934400D14C53 /* pomodoSound.m4a in Resources */,
83BFAE78213CDE91004EF801 /* GiGaSettingsViewCell.xib in Resources */, 83BFAE78213CDE91004EF801 /* GiGaSettingsViewCell.xib in Resources */,
83346AC1212BB50A0054D597 /* PassWordResetVC.xib in Resources */, 83346AC1212BB50A0054D597 /* PassWordResetVC.xib in Resources */,
8390117C214E20B2004CA790 /* citys.json in Resources */,
83BDC0592147B89900E74E0D /* GiGaAnswerViewCell.xib in Resources */, 83BDC0592147B89900E74E0D /* GiGaAnswerViewCell.xib in Resources */,
83346AD1212BF5B70054D597 /* useragreement.html in Resources */, 83346AD1212BF5B70054D597 /* useragreement.html in Resources */,
838762D9214B9EF80039D241 /* GIGaUserIDViewCell.xib in Resources */, 838762D9214B9EF80039D241 /* GIGaUserIDViewCell.xib in Resources */,
838762E8214B9FA60039D241 /* GIGaUserCityViewCell.xib in Resources */, 838762E8214B9FA60039D241 /* GIGaUserCityViewCell.xib in Resources */,
83BFAE68213CCF10004EF801 /* GiGaMineUserViewCell.xib in Resources */, 83BFAE68213CCF10004EF801 /* GiGaMineUserViewCell.xib in Resources */,
833DE8D7214FF7F8009D4329 /* city1.js in Resources */,
8340BFA9213E65CA008F22E4 /* GIGACommonLocalizabe.strings in Resources */, 8340BFA9213E65CA008F22E4 /* GIGACommonLocalizabe.strings in Resources */,
83835BA8212E4748001480F2 /* MAssaageCenterCell.xib in Resources */, 83835BA8212E4748001480F2 /* MAssaageCenterCell.xib in Resources */,
8361B3D3212155C300238FEB /* Assets.xcassets in Resources */, 8361B3D3212155C300238FEB /* Assets.xcassets in Resources */,
@ -1523,7 +1520,6 @@
83773FBC214769230014EE4C /* ExercisesModel.m in Sources */, 83773FBC214769230014EE4C /* ExercisesModel.m in Sources */,
83835BD0212E8B9C001480F2 /* GiGaQuestionModel.m in Sources */, 83835BD0212E8B9C001480F2 /* GiGaQuestionModel.m in Sources */,
83835BAF212E4FCD001480F2 /* MessageListViewCell.m in Sources */, 83835BAF212E4FCD001480F2 /* MessageListViewCell.m in Sources */,
8390117D214E20B2004CA790 /* JYAddressPicker.m in Sources */,
8361B3D9212155C300238FEB /* main.m in Sources */, 8361B3D9212155C300238FEB /* main.m in Sources */,
83773FBF214791E10014EE4C /* GIGaQuestionSlider.m in Sources */, 83773FBF214791E10014EE4C /* GIGaQuestionSlider.m in Sources */,
83901179214E20B2004CA790 /* LYSDatePickerTypeBase.m in Sources */, 83901179214E20B2004CA790 /* LYSDatePickerTypeBase.m in Sources */,
@ -1549,6 +1545,7 @@
83BFAE67213CCF10004EF801 /* GiGaMineUserViewCell.m in Sources */, 83BFAE67213CCF10004EF801 /* GiGaMineUserViewCell.m in Sources */,
8392900C2134F9F80077D2E8 /* GiGaCommentView.m in Sources */, 8392900C2134F9F80077D2E8 /* GiGaCommentView.m in Sources */,
839290062134F4240077D2E8 /* LXDanMuManager.m in Sources */, 839290062134F4240077D2E8 /* LXDanMuManager.m in Sources */,
833DE8E52150169F009D4329 /* JYAddressPicker.m in Sources */,
83901171214E20B2004CA790 /* LYSDatePickerLabel.m in Sources */, 83901171214E20B2004CA790 /* LYSDatePickerLabel.m in Sources */,
838762E2214B9F580039D241 /* GiGaUserSexViewCell.m in Sources */, 838762E2214B9F580039D241 /* GiGaUserSexViewCell.m in Sources */,
839290052134F4240077D2E8 /* LXDanMuTrackView.m in Sources */, 839290052134F4240077D2E8 /* LXDanMuTrackView.m in Sources */,

View File

@ -1,19 +0,0 @@
//
// JYAddressPicker.h
// LakalaClient
//
// Created by flying on 2018/8/17.
// Copyright © 2018年 LR. All rights reserved.
//
#import <UIKit/UIKit.h>
typedef void (^SelectedItemBlock)(NSArray *addressArr);
@interface JYAddressPicker : UIViewController
+(JYAddressPicker *)jy_showAt:(UIViewController *)vc;
+(JYAddressPicker *)jy_showAt:(UIViewController *)vc defaultShow:(NSArray *)values;
@property (nonatomic, copy) SelectedItemBlock selectedItemBlock;
@end

View File

@ -1,251 +0,0 @@
//
// JYAddressPicker.m
// LakalaClient
//
// Created by flying on 2018/8/17.
// Copyright © 2018 LR. All rights reserved.
//
#import "JYAddressPicker.h"
#define PickerHeight 180
#define PickerToolBarHeight 44
@interface JYAddressPicker ()<UIPickerViewDelegate,UIPickerViewDataSource>
//picker
@property(nonatomic,strong)NSMutableArray *showAddressArr;
//picker
@property(nonatomic,strong)NSMutableArray *showIndexs;
@property (nonatomic, strong) UIView *pickerContainerView;
@property (nonatomic, strong) UIPickerView *pickerView;
@end
@implementation JYAddressPicker
- (void)viewDidLoad {
[super viewDidLoad];
self.view.backgroundColor = [UIColor colorWithRed:0.0 green:0.0 blue:0.0 alpha:0.4];
[self initUI];
for (NSInteger index = 0; index < [self.showIndexs count]; index ++) {
[self.pickerView selectRow:[[self.showIndexs objectAtIndex:index] integerValue] inComponent:index animated:NO];
}
}
-(void)initUI{
self.pickerContainerView = [[UIView alloc] initWithFrame:CGRectMake(0, [UIScreen mainScreen].bounds.size.height - (PickerHeight + PickerToolBarHeight), [UIScreen mainScreen].bounds.size.width, PickerHeight + PickerToolBarHeight)];
UIToolbar *toolBar = [[UIToolbar alloc]initWithFrame:CGRectMake(0, 0, [UIScreen mainScreen].bounds.size.width, PickerToolBarHeight)];
toolBar.barTintColor = [UIColor whiteColor];
UIBarButtonItem *noSpace = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemFixedSpace target:nil action:nil];
noSpace.width=10;
UIBarButtonItem *doneBtn = [[UIBarButtonItem alloc] initWithTitle:@"确定" style:UIBarButtonItemStylePlain target:self action:@selector(done:)];;
doneBtn.tintColor = [UIColor grayColor];
UIBarButtonItem *cancelBtn = [[UIBarButtonItem alloc] initWithTitle:@"取消" style:UIBarButtonItemStylePlain target:self action:@selector(cancel:)];
cancelBtn.tintColor = [UIColor grayColor];
UIBarButtonItem *flexSpace = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemFlexibleSpace target:nil action:nil];
[toolBar setItems:[NSArray arrayWithObjects:noSpace,cancelBtn,flexSpace,doneBtn,noSpace, nil]];
UILabel *titleLabel = [UILabel new];
titleLabel.frame = CGRectMake(0, 0, 200, PickerToolBarHeight);
titleLabel.center = toolBar.center;
titleLabel.textAlignment = NSTextAlignmentCenter;
titleLabel.textColor = [UIColor darkTextColor];
titleLabel.text = @"省市区选择";
[toolBar addSubview:titleLabel];
self.pickerView = [[UIPickerView alloc] initWithFrame:CGRectMake(0, PickerToolBarHeight, [UIScreen mainScreen].bounds.size.width, PickerHeight)];
self.pickerView.dataSource = self;
self.pickerView.delegate = self;
self.pickerView.backgroundColor = [UIColor whiteColor];
[self.pickerContainerView addSubview:toolBar];
[self.pickerContainerView addSubview:self.pickerView];
[self.view addSubview:self.pickerContainerView];
}
#pragma mark-- UIPickerViewDataSource
//
- (NSInteger)numberOfComponentsInPickerView:(UIPickerView *)pickerView
{
return [self.showIndexs count];
}
//
- (NSInteger)pickerView:(UIPickerView *)pickerView numberOfRowsInComponent:(NSInteger)component
{
return [[self.showAddressArr objectAtIndex:component] count];
}
#pragma mark-- UIPickerViewDelegate
-(UIView *)pickerView:(UIPickerView *)pickerView viewForRow:(NSInteger)row forComponent:(NSInteger)component reusingView:(UIView *)view
{
UILabel *label = (id)view;
if (!label)
{
label= [[UILabel alloc] initWithFrame:CGRectMake(0.0f, 0.0f, [pickerView rowSizeForComponent:component].width, [pickerView rowSizeForComponent:component].height)];
label.textAlignment = NSTextAlignmentCenter;
label.textColor = [UIColor blackColor];
NSDictionary *dic = [[self.showAddressArr objectAtIndex:component] objectAtIndex:row];
label.text = dic[@"text"];
}
return label;
}
//
-(void)pickerView:(UIPickerView *)pickerView didSelectRow:(NSInteger)row inComponent:(NSInteger)component
{
NSArray *columnItems = [self.showAddressArr objectAtIndex:component];
NSDictionary *selectedItem = [columnItems objectAtIndex:row];
if ([selectedItem[@"childrens"] count] == 0) {
//
[self.showIndexs replaceObjectAtIndex:component withObject:@(row)];
}else{
NSUInteger replaceIdx = component;
BOOL next = true;
while (next) {
if (component == replaceIdx) {
[self.showIndexs replaceObjectAtIndex:replaceIdx withObject:@(row)];
}else{
if (replaceIdx < [self.showIndexs count]) {
NSArray *childrens = selectedItem[@"childrens"];
[self.showAddressArr replaceObjectAtIndex:replaceIdx withObject:childrens];
[self.showIndexs replaceObjectAtIndex:replaceIdx withObject:@(0)];
selectedItem = [childrens firstObject];
}else{
next = false;
}
}
replaceIdx ++;
}
}
[pickerView reloadAllComponents];
//
for (NSInteger index = 0; index < [self.showIndexs count]; index ++) {
[self.pickerView selectRow:[[self.showIndexs objectAtIndex:index] integerValue] inComponent:index animated:NO];
}
}
-(instancetype)initWith:(NSArray *)defaultValues{
if (self = [super init]) {
self.modalPresentationStyle = UIModalPresentationOverCurrentContext;
self.showIndexs = [NSMutableArray array];
self.showAddressArr = [NSMutableArray array];
//json
NSString *jsonPath = [[NSBundle mainBundle] pathForResource:@"citys" ofType:@"json"];
NSData *data = [[NSData alloc] initWithContentsOfFile:jsonPath];
NSError *error = nil;
NSArray *citysArr = [NSJSONSerialization JSONObjectWithData:data options:NSJSONReadingMutableContainers error:&error];
//
[self defaultShowValue:[NSMutableArray arrayWithArray:defaultValues] items:citysArr];
}
return self;
}
+(JYAddressPicker *)jy_showAt:(UIViewController *)vc{
JYAddressPicker *addressPicker = [[JYAddressPicker alloc] initWith:@[@"",@"",@""]];
[vc presentViewController:addressPicker animated:YES completion:^{
}];
return addressPicker;
}
+(JYAddressPicker *)jy_showAt:(UIViewController *)vc defaultShow:(NSArray *)values{
NSParameterAssert(values);
JYAddressPicker *addressPicker = [[JYAddressPicker alloc] initWith:values];
[vc presentViewController:addressPicker animated:YES completion:^{
}];
return addressPicker;
}
-(void)defaultShowValue:(NSMutableArray *)values items:(NSArray *)items
{
[items enumerateObjectsUsingBlock:^(NSDictionary *obj, NSUInteger idx, BOOL * _Nonnull stop) {
if ([@"" isEqualToString:[values firstObject]])
{
//valuesvalues@""
[self.showIndexs addObject:@(0)];
[values removeObjectAtIndex:0];
[self.showAddressArr addObject:items];
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];
NSArray *childs = obj[@"childrens"];
[self defaultShowValue:values items:childs];
}
}];
}
#pragma mark--
-(void)done:(id)sender{
if (self.selectedItemBlock) {
NSMutableArray *resultArr = [NSMutableArray array];
[self.showAddressArr enumerateObjectsUsingBlock:^(NSArray *objArr, NSUInteger idx, BOOL * _Nonnull stop) {
NSDictionary *selectedItem = [objArr objectAtIndex:[[self.showIndexs objectAtIndex:idx] integerValue]];
[resultArr addObject:selectedItem];
}];
self.selectedItemBlock(resultArr);
}
[self hide];
}
#pragma mark--
-(void)cancel:(id)sender{
[self hide];
}
-(void)hide{
[self dismissViewControllerAnimated:YES completion:^{
}];
}
- (void)didReceiveMemoryWarning {
[super didReceiveMemoryWarning];
// Dispose of any resources that can be recreated.
}
@end

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@ -186,9 +186,9 @@
weakify(self); weakify(self);
addressPicker.selectedItemBlock = ^(NSArray *addressArr) { addressPicker.selectedItemBlock = ^(NSArray *addressArr) {
NSString *province = [addressArr objectAtIndex:0][@"text"]; NSString *province = [addressArr objectAtIndex:0][@"name"];
NSString *city = [addressArr objectAtIndex:1][@"text"]; NSString *city = [addressArr objectAtIndex:1][@"name"];
NSString *county = [addressArr objectAtIndex:2][@"text"]; NSString *county = [addressArr objectAtIndex:2][@"name"];
NSString *addres = [NSString stringWithFormat:@"%@%@%@",province,city,county]; NSString *addres = [NSString stringWithFormat:@"%@%@%@",province,city,county];
GILog(@"%@",addres); GILog(@"%@",addres);
GIGaUserCityViewCell *cell = [tableView cellForRowAtIndexPath:indexPath]; GIGaUserCityViewCell *cell = [tableView cellForRowAtIndexPath:indexPath];