美团HD(5)-选择城市
DJSelectCityViewController.m
#import "DJSelectCityViewController.h"
#import "DJConstantValue.h"
#import "DJCityGroup.h"
#import "MJExtension.h" @interface DJSelectCityViewController ()<UITableViewDataSource,UITableViewDelegate,UISearchBarDelegate> /** 城市组列表 */
@property (nonatomic,strong) NSMutableArray *cityGroups;
@property (weak, nonatomic) IBOutlet UITableView *cityTableView; @end @implementation DJSelectCityViewController - (void)viewDidLoad {
[super viewDidLoad]; self.title = @"选择城市";
// 设置右侧索引栏字体颜色
self.cityTableView.sectionIndexColor = [UIColor blackColor]; [self setupNavLeftItem];
[self loadCityData]; } - (void)setupNavLeftItem { UIBarButtonItem *closeItem = [UIBarButtonItem itemWithTarget:self action:@selector(close) image:@"btn_navigation_close" highlighImage:@"btn_navigation_close_hl"]; self.navigationItem.leftBarButtonItem = closeItem; } /** 加载城市数据 */
- (void)loadCityData { self.cityGroups = [DJCityGroup mj_objectArrayWithFilename:@"cityGroups.plist"]; } /** 关闭当前界面 */
- (void)close { [self dismissViewControllerAnimated:YES completion:nil]; } - (void)didReceiveMemoryWarning {
[super didReceiveMemoryWarning];
// Dispose of any resources that can be recreated.
} #pragma mark - UITableView 数据源方法 - (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView { return self.cityGroups.count; } - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section { DJCityGroup *cityGroup = self.cityGroups[section];
return cityGroup.cities.count; } - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath { static NSString *ID = @"cityGroup";
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:ID];
if (!cell) {
cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleSubtitle reuseIdentifier:ID];
}
DJCityGroup *cityGroup = self.cityGroups[indexPath.section];
NSString *cityName = cityGroup.cities[indexPath.row]; cell.textLabel.text = cityName; return cell;
} #pragma mark - tableView 代理方法 - (NSString *)tableView:(UITableView *)tableView titleForHeaderInSection:(NSInteger)section { DJCityGroup *cityGroup = self.cityGroups[section];
return cityGroup.title; } - (NSArray<NSString *> *)sectionIndexTitlesForTableView:(UITableView *)tableView { return [self.cityGroups valueForKeyPath:@"title"]; } #pragma mark - UISearchBar 代理方法 /** SearchBar开始编辑 */
- (void)searchBarTextDidBeginEditing:(UISearchBar *)searchBar { // 隐藏导航栏
[self.navigationController setNavigationBarHidden:YES animated:YES]; } /** SearchBar结束编辑 */
- (void)searchBarTextDidEndEditing:(UISearchBar *)searchBar { // 显示导航栏
[self.navigationController setNavigationBarHidden:NO animated:YES]; } @end
最终效果:
美团HD(5)-选择城市的更多相关文章
- LOJ #6192. 「美团 CodeM 复赛」城市网络 (树上倍增)
#6192. 「美团 CodeM 复赛」城市网络 内存限制:64 MiB 时间限制:500 ms 标准输入输出 题目描述 有一个树状的城市网络(即 nnn 个城市由 n−1n-1n−1 条道路连接 ...
- LibreOJ #6192. 「美团 CodeM 复赛」城市网络
#6192. 「美团 CodeM 复赛」城市网络 内存限制:64 MiB时间限制:500 ms标准输入输出 题目类型:传统评测方式:文本比较 上传者: sqc 提交提交记录统计讨论测试数据 题目描 ...
- 美团 CodeM 复赛」城市网络
美团 CodeM 复赛」城市网络 内存限制:64 MiB时间限制:500 ms标准输入输出 题目描述 有一个树状的城市网络(即 nnn 个城市由 n−1n-1n−1 条道路连接的连通图),首都为 11 ...
- h5手机端下拉选择城市
<!doctype html><html> <head> <meta http-equiv="Content-Type& ...
- jquery实现输入框聚焦,键盘上下键选择城市
在最近有个项目中 需要实现当文本框聚焦的时候,可以键盘上下键选择内容,按enter键的时候,把内容传到输入框中,如图所示: 实现代码如下: /** *输入框聚焦,键盘上下键选择城市 */ ;(func ...
- 每天一个JavaScript实例-动态省份选择城市
<!DOCTYPE html> <html> <head> <meta http-equiv="Content-Type" content ...
- jQuery 选择城市,显示对应的即时时区时间
因客户需要,我们CRM系统中,jQuery 弄个时区插件 如图: HTML: <div id="cityDate"> <i class="P_arrow ...
- 美团HD(9)-监听点击城市
DJSelectCityViewController.h // 点击城市发出通知 - (void)tableView:(UITableView *)tableView didSelectRowAtIn ...
- 【代码笔记】iOS-先选择城市,然后,跳转Tabbar
一,效果图. 二,工程图. 三,代码. ChooseCityViewController.h #import <UIKit/UIKit.h> @interface ChooseCityVi ...
随机推荐
- ajax请求成功后打开新开窗口(window.open())被拦截的解决方法
问题:今天在做项目时需要在ajax请求成功后打开一个新的窗口,此时遇到浏览拦截了新窗口的问题,尝试在ajax 回调函数中模拟执行 click 或者 submit 等用户行为(trigger('clic ...
- 腾讯云CentOS系统配置apache和tomcat
本文使用yum软件包管理工具基于CentOS7.2版本配置apache和tom. 云服务器选购完毕后,安装Xshell软件,输入用户名密码即可远程登陆登录(centos用户名默认是root). 1,下 ...
- OSI七层模型详解 TCP/IP协议
总结 OSI中的层 功能 TCP/IP协议族 应用层 文件传输,电子邮件,文件服务,虚拟终端 TFTP,HTTP,SNMP,FTP,SMTP,DNS,Telnet 等等 表示层 数据格式化,代码转 ...
- [转][iOS]NSHashTable & NSMapTable
NSSet and NSDictionary, along with NSArray are the workhorse collection classes of Foundation. Unlik ...
- Windows批处理:自动部署常用软件(静默安装)
一.简介 最近一直在测试使用域组策略自动部署软件,效果并不理想.首先,主机必须加入域才能让策略生效.其实是Windows Server 2012 R2只支持.msi格式的安装包,所以部署前需将软件重新 ...
- Linux下的TeXlive 2015 中文问题
Update: 今日突然发现,我的xeLaTeX编译生成的pdf中文字在TeXMaker内置viewer.evince下查看均无法显示中文,中文字显示为空白,英语正常:但FireFox.Chrome浏 ...
- .Net中DLL冲突解决(真假美猴王)
<西游记>中真假美猴王让人着实难以区分,但是我们熟知了其中的细节也不难把他们剥去表象分别出来.对问题不太关心的可以直接调到文中关于.Net文件版本的介绍 问题 最近在编译AKKA.net ...
- 4种解决json日期格式问题的办法
4种解决json日期格式问题的办法 开发中有时候需要从服务器端返回json格式的数据,在后台代码中如果有DateTime类型的数据使用系统自带的工具类序列化后将得到一个很长的数字表示日期数据,如下 ...
- 011商城项目:图片服务器的安装---nginx
这个是电商的项目,不是传统项目,所以给图片单独架一台服务器. 我们看上图: 用户上传图片时上传到Tomcat1或者Tomcat2.然后Tomcat1和Tomcat2通过FTP服务把图片上传到图片服务器 ...
- channel Golang
Golang, 以17个简短代码片段,切底弄懂 channel 基础 (原创出处为本博客:http://www.cnblogs.com/linguanh/) 前序: 因为打算自己搞个基于Golang的 ...