开箱即用,一个零配置,快速集成的**行政区域选择Controller
To run the example project, clone the repo, and run pod install
from the Example directory first.
iOS 9.0
CNCitySelector is available through CocoaPods. To install it, simply add the following line to your Podfile:
pod 'CNCitySelector'
- 初始化CNCitySelectController
CNCitySelectController *vc = [CNCitySelectController alloc] initWithFrame:frame];
- 设置城市数据database, 本repo自带GB2260的城市数据库,如果你需要使用自己的数据库,可以实现
CNCityDatabase
的数据接口
// GB2260实现了CNCityDatabase协议
vc.datasource = [GB2260 shardInstance];
// self遵循CNCitySelectDelegate协议
vc.delegate = self;
- 选择城市后回调
CNCitySelectDelegate
- (void)didSelectRegion:(CNRegion *)region {
NSLog(@"Select city: %@", region.name);
}
That's all
Enix Yu, [email protected]
CNCitySelector is available under the MIT license. See the LICENSE file for more info.