城市选择器

加入收藏
已有 102 人收藏

介绍:
    导入 "BAddressPickerController.h"

    

    BAddressPickerController *addressPickerController = [[BAddressPickerController alloc] initWithFrame:self.view.frame];

    

    addressPickerController.dataSource = self;

    

    addressPickerController.delegate = self;

    

    [self addChildViewController:addressPickerController]; [self.view addSubview:addressPickerController.view];

    

    实现BAddressPickerDataSource数据源协议

    (NSArray*)arrayOfHotCitiesInAddressPicker:(BAddressPickerController *)addressPicker;

    实现BAddressPickerDelegate代理协议

    (void)addressPicker:(BAddressPickerController *)addressPicker didSelectedCity:(NSString *)city;

    

    (void)beginSearch:(UISearchBar *)searchBar;

    

    (void)endSearch:(UISearchBar *)searchBar;

测试环境:
  [Code4App]编译测试
效果图:
  • iOS / iPhone 导入 "BAddressPickerController.h"<br /><br />&nbsp;&nbsp;&nbsp;&nbsp;<br /><br />&nbsp;&nbsp;&nbsp;&nbsp;BAddressPickerController *addressPickerController = [[BAddressPickerController alloc] initWithFrame:self.view.frame];<br /><br />&nbsp;&nbsp;&nbsp;&nbsp;<br /><br />&nbsp;&nbsp;&nbsp;&nbsp;addressPickerController.dataSource = self;<br /><br />&nbsp;&nbsp;&nbsp;&nbsp;<br /><br />&nbsp;&nbsp;&nbsp;&nbsp;addressPickerController.delegate = self;<br /><br />&nbsp;&nbsp;&nbsp;&nbsp;<br /><br />&nbsp;&nbsp;&nbsp;&nbsp;[self addChildViewController:addressPickerController]; [self.view addSubview:addressPickerController.view];<br /><br />&nbsp;&nbsp;&nbsp;&nbsp;<br /><br />&nbsp;&nbsp;&nbsp;&nbsp;实现BAddressPickerDataSource数据源协议<br /><br />&nbsp;&nbsp;&nbsp;&nbsp;(NSArray*)arrayOfHotCitiesInAddressPicker:(BAddressPickerController *)addressPicker;<br /><br />&nbsp;&nbsp;&nbsp;&nbsp;实现BAddressPickerDelegate代理协议<br /><br />&nbsp;&nbsp;&nbsp;&nbsp;(void)addressPicker:(BAddressPickerController *)addressPicker didSelectedCity:(NSString *)city;<br /><br />&nbsp;&nbsp;&nbsp;&nbsp;<br /><br />&nbsp;&nbsp;&nbsp;&nbsp;(void)beginSearch:(UISearchBar *)searchBar;<br /><br />&nbsp;&nbsp;&nbsp;&nbsp;<br /><br />&nbsp;&nbsp;&nbsp;&nbsp;(void)endSearch:(UISearchBar *)searchBar;
代码评论:
登录后方可评论

  
  • 2016-02-19 15:16:27
    回复
    定位怎么改,我用真机定位也显示不了
    登录后方可评论

      
  • 2016-02-17 20:01:04
    回复
    作者你好,请问您如果我想把你的这个城市选择器放到我的一个练习项目里应该做些什么。。。谢谢
    登录后方可评论

      
  • 2016-01-30 01:18:35
    回复
    作者你好,在iPhone6真机上运行时。 发现搜索城市,出现城市列表后,下拉界面,顶部会出现navigationbar和tableView的当前城市,还望作者查看一下。
    登录后方可评论

      
  • 2016-01-26 16:02:30
    回复
    怎么定位不了啊
    登录后方可评论

      
  • 2016-01-25 16:14:07
    回复
    请加入ios开发群(Oc)的QQ群: 281103593,可以问很多知识
    登录后方可评论

      
  • 2016-01-25 10:59:59
    回复
    最近访问的城市 点击会有crash
    登录后方可评论