iOS开发:城市选择器集成

一、简介

该项目集成了三种类型的城市选择器:

  • 1、XXCityPickerView 省市区,可以分级:1省 2省-市 3省-市-区
  • 2、SQSelectAddress 省市区乡/镇,页面跳转
  • 3、RattanCityPicker 省市区,包含邮编地址,开放多个属性设置的接口

##二、XXCityPickerView使用

####1、从该项目导入【XXCityPickerView】文件包
####2、 导入系统库 :libsqlite3.tbd
####3、方法实现

#import "XXCityPickerView.h"

@interface ViewController ()<XXCityPickerViewDelegate>

@property(nonatomic,strong)XXCityPickerView *cityPicker;

@end

@implementation ViewController

- (void)viewDidLoad {
    [super viewDidLoad];
}

///方法调用
-(void)clickAction{
    [self cityPicker];
}

- (XXCityPickerView *)cityPicker{
    if (_cityPicker == nil){
        // 初始化  设置类别   1省  2省-市  3省-市-区
        _cityPicker = [[XXCityPickerView alloc]initWithComponents:3];
        // 设置代理
        _cityPicker.delegate = self;
        [self.view addSubview:_cityPicker];
    }
    return  _cityPicker;
}	

####4、代理实现

// ---- 【XXCityPickerViewDelegate】
// 取消
- (void)XXCityPickerViewLeftAction{
    [self removeCityPickerView];
}
// 完成
- (void)XXCityPickerViewRightAction:(XXCityPickerView *)picker andCity:(NSString *)city andData:(NSMutableDictionary *)dic{
    [self removeCityPickerView];
    NSLog(@"???XXCityPickerView:\n city= %@   dic= %@",city,dic);
}

-(void)removeCityPickerView{
    if (_cityPicker) {
        [_cityPicker removeFromSuperview];
        _cityPicker = nil;
    }
}

##三、SQSelectAddress使用

####1、导入【SQSelectAddress】文件包
####2、调用【SQSelectAddressViewController.h】类
####3、协议声明

@interface ViewController ()<SQSelectAddressViewControllerDelegate>

####4、方法实现

pragma mark -
#pragma mark - SQSelectAddress
///页面添加
-(void)sqSelectAddressPockerView{
    SQSelectAddressViewController *selectAddressVC = [[SQSelectAddressViewController alloc] init];
    //签署协议
    selectAddressVC.delegate = self;
    selectAddressVC.animating = NO;
    selectAddressVC.footerBg_color = [UIColor greenColor];
    selectAddressVC.headerBg_color = [UIColor greenColor];
    selectAddressVC.title_font = [UIFont systemFontOfSize:25];
    selectAddressVC.titleText_color = [UIColor orangeColor];
    [self presentViewController:selectAddressVC animated:YES completion:nil];
}

####5、代理协议实现

- (void)selectAddressViewController:(SQSelectAddressViewController *)selectController selectedDetailAdreess:(NSString *)address townCode:(NSString *)townCode{
    NSLog(@"??SQSelectAddress:\n地址=%@  编码=%@",address,townCode);
}

##四、RattanCityPicker使用

####1、导入[RattanCityPicker]文件包

####2、方法实现

#import "RattanCityPicker.h"

#pragma mark -
#pragma mark - RattanCityPicker

-(void)rattanCity{
    RattanCityPicker *picker=[[RattanCityPicker alloc] init];
    picker.animation_dur = 0.3;
    picker.toolViewBg_color =[UIColor greenColor];
    picker.componentFir_font = [UIFont systemFontOfSize:16];
    picker.componentStrFir_color = [UIColor redColor];;
    picker.componentBgFir_color = [UIColor lightGrayColor];
    picker.selectLblStr_font = [UIFont systemFontOfSize:20];
    picker.selectLblStr_color = [UIColor redColor];
    //点击确定按钮代码块调用
    picker.sureBtnBlock = ^(){

    };
    //获取选择的城市的信息
    [picker cityPikerGetSelectCity:^(NSMutableDictionary *dicSelectCity) {
        [self setTextLbl:dicSelectCity];
        NSLog(@"??RattanCityPicker:\n%@",dicSelectCity);
    }];
}

演示

SQSelectAddress

XXCityPickerView

RattanCityPicker

  • 源码地址:https://gitee.com/chenzm_186/CityPickerDemo
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

瓜子三百克

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值