Code Monkey home page Code Monkey logo

addresspickerdemo's Introduction

AddressPickerDemo

Build Platform License

**省市区地址选择器

Feature

  • 支持iPhone & iPad
  • 适配横竖屏

Requirements

  • Xcode8.0+
  • iOS7.0+

Usage

  1. 将AddressPicker文件夹拖拽到项目,并导入头文件: #import "XPAddressPicker.h"

  2. 实例化XPAddressPicker并显示

XPAddressPicker *picker = [[XPAddressPicker alloc] init];
picker.delegate = self;
picker.pickerStyle = XPAddressPickerStyleDefault;
// [picker setSelectionAddressForId:@"450881"];
[picker show];
  1. 遵守XPAddressPickerDelegate协议,并实现-addressPicker:didFinishPickingAddress:方法获取回调数据
- (void)addressPicker:(XPAddressPicker *)picker didFinishPickingAddress:(NSDictionary<NSString *,NSDictionary *> *)info {
    NSDictionary *province = info[XPAddressPickerProvinceKey]; // 省份信息
    NSDictionary *city = info[XPAddressPickerCityKey]; // 城市信息
    NSDictionary *county = info[XPAddressPickerCountyKey]; // 市区信息
    
    NSString *provinceName = province[XPAddressPickerNameKey];
    NSString *cityName = city[XPAddressPickerNameKey];
    
    NSString *ID = city[XPAddressPickerIdKey];
    NSMutableString *string = [[NSMutableString alloc] initWithFormat:@"%@ %@", provinceName, cityName];
    if (nil != county) {
        NSString *countyName = county[XPAddressPickerNameKey];
        ID = county[XPAddressPickerIdKey];
        [string appendFormat:@" %@", countyName];
    }
    [string appendFormat:@" id:%@", ID];
    
    UIAlertView *alertView = [[UIAlertView alloc] initWithTitle:@"您选择的地址是:" message:string delegate:nil cancelButtonTitle:@"OK" otherButtonTitles:nil, nil];
    [alertView show];
}

Preview

GIF

XPAddressPickerStyle

  • XPAddressPickerStyleDefault

  • XPAddressPickerStyleSingle

  • XPAddressPickerStyleDouble

License

基于MIT License进行开源,详细内容请参阅LICENSE文件。

addresspickerdemo's People

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.