中國行政區劃選擇器:ChineseSubdivisionsPicker

中國行政區劃選擇器

ChineseSubdivisionsPicker is a simple Chinese Subdivisions picker inherited from UIPickerView and written in Swift.

中國行政區劃選擇器繼承自 UIPickerView,使用 swift 實現。

中國行政區劃選擇器:ChineseSubdivisionsPicker

You can let user pick province, city and district data from it.

用戶可以選擇省、市或區。你可以定制選擇器的最小選擇粒度。

Campatible from iOS7 to iOS9.

Usage

let myPicker = ChineseSubdivisionsPicker() 
//You can also use Interface Builder to create a ChineseSubdivisionsPicker
myPicker.pickerType = .District
myPicker.pickerDelegate = self

Basics

pickerType: ChineseSubdivisionsPicker.ChineseSubdivisionsPickerType

Available picker types are.Province.Cityand.DistrictPicker type is.Districtin default.

可選的選擇器類型為.Province(只可選擇省份).City(可選擇省市) and.District(可選擇省市區),默認的選擇器類型是.District(可選擇省市區)。

pickerDelegate: ChineseSubdivisionsPickerDelegate

You should implementsubdivisionsPickerDidUpdate()in your pickerDelegate (a UIViewController in usual) to receive callback when picker value is changed.

你需要在你的 pickerDelegate(通常是一個 UIViewController)里實現subdivisionsPickerDidUpdate()方法,ChineseSubdivisionsPicker 會在更新選定的省市區時調用這個方法。

province, city, district: String?

You can fetch current province, city and district name.

可通過province,city,district屬性獲取到目前選擇的省市區的名字。

Note

ChangingdataSourceordelegateof ChineseSubdivisionsPicker will not work. You should changepickerDelegateinstead for receiving callback.

注意,ChineseSubdivisionsPicker 的dataSource和delegate是無法修改的 (否則 Picker 無法正常工作)。如果你想要接受回調,應該修改pickerDelegate屬性。

Installation

CocoaPods

ChineseSubdivisionsPicker is available through CocoaPods. To install it, simply add the following lines to your Podfile:

iOS8 or later

use_frameworks!
pod 'ChineseSubdivisionsPicker'

Due to iOS limitation, you can not intergrate swift file (such as ChineseSubdivisionsPicker) with cocoapods in project which deployment targer is iOS7. But you can followTo manually add to your projectbelow.

To manually add to your project

  1. Add all files inChineseSubdivisionsPicker/to your project
  2. that's all!

項目主頁:http://www.baiduhome.net/lib/view/home/1449730657019

 本文由用戶 jopen 自行上傳分享,僅供網友學習交流。所有權歸原作者,若您的權利被侵害,請聯系管理員。
 轉載本站原創文章,請注明出處,并保留原始鏈接、圖片水印。
 本站是一個以用戶分享為主的開源技術平臺,歡迎各類分享!