DJHomeViewController.m

/** 设置导航栏左侧内容 */
- (void)setupLeftNavItem { // Logo
UIImageView *logoView = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"icon_meituan_logo"]];
UIBarButtonItem *logoItem = [[UIBarButtonItem alloc] initWithCustomView:logoView]; // 类别
DJNavItem *categoryView = [DJNavItem item];
[categoryView addTarget:self action:@selector(onCategoryNavItemDidClick)];
UIBarButtonItem *categoryItem = [[UIBarButtonItem alloc] initWithCustomView:categoryView];
self.categoryItem = categoryItem; // 地区
DJNavItem *areaView = [DJNavItem item];
[areaView addTarget:self action:@selector(onAreaNavItemDidClick)];
UIBarButtonItem *areaItem = [[UIBarButtonItem alloc] initWithCustomView:areaView];
self.areaItem = areaItem; // 排序
DJNavItem *sortView = [DJNavItem item];
[sortView addTarget:self action:@selector(onSortNavItemDidClick)];
UIBarButtonItem *sortItem = [[UIBarButtonItem alloc] initWithCustomView:sortView];
self.sortItem = sortItem; self.navigationItem.leftBarButtonItems = @[logoItem,categoryItem,areaItem,sortItem]; } #pragma mark - 导航按钮被点击
- (void)onCategoryNavItemDidClick { // 创建将要显示的Controller
DJCategoryViewController *categoryVC = [[DJCategoryViewController alloc] init];
// 设置控制器View的显示大小
categoryVC.preferredContentSize = CGSizeMake(, );
// 设置Modal类型
categoryVC.modalPresentationStyle = UIModalPresentationPopover;
// 获取Popover
UIPopoverPresentationController *categoryPopover = categoryVC.popoverPresentationController;
// 相对于哪个View来显示
categoryPopover.sourceView = self.categoryItem.customView;
// 显示位置
categoryPopover.sourceRect = self.categoryItem.customView.bounds;
// 设置popover箭头的显示方向
categoryPopover.permittedArrowDirections = UIPopoverArrowDirectionAny;
// 跳转
[self presentViewController:categoryVC animated:YES completion:nil]; }

DJNavDropView.m

#import "DJNavDropView.h"
#import "DJCategory.h" @interface DJNavDropView()<UITableViewDataSource,UITableViewDelegate> @property (weak, nonatomic) IBOutlet UITableView *mainTableView; @end @implementation DJNavDropView + (instancetype)dropView { return[[[NSBundle mainBundle] loadNibNamed:@"DJNavDropView" owner:nil options:nil] lastObject]; } - (void)setCategoryList:(NSArray *)categoryList { _categoryList = categoryList; // 刷新数据
[self.mainTableView reloadData]; } #pragma mark - TableView 数据源方法 - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section { return self.categoryList.count; } - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath { static NSString *ID = @"category";
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:ID];
if (!cell) {
cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleSubtitle reuseIdentifier:ID];
} DJCategory *categoryItem = self.categoryList[indexPath.row]; cell.textLabel.text = categoryItem.name;
cell.imageView.image = [UIImage imageNamed:categoryItem.icon]; return cell;
} @end

最终效果:

美团HD(3)-加载分类导航数据的更多相关文章

  1. 【JAVAWEB学习笔记】网上商城实战2:异步加载分类、Redis缓存分类和显示商品

    网上商城实战2 今日任务 完成分类模块的功能 完成商品模块的功能 1.1      分类模块的功能: 1.1.1    查询分类的功能: 1.1.2    查询分类的代码实现: 1.1.2.1  创建 ...

  2. ASP.NET MVC深入浅出(被替换) 第一节: 结合EF的本地缓存属性来介绍【EF增删改操作】的几种形式 第三节: EF调用普通SQL语句的两类封装(ExecuteSqlCommand和SqlQuery ) 第四节: EF调用存储过程的通用写法和DBFirst模式子类调用的特有写法 第六节: EF高级属性(二) 之延迟加载、立即加载、显示加载(含导航属性) 第十节: EF的三种追踪

    ASP.NET MVC深入浅出(被替换)   一. 谈情怀-ASP.NET体系 从事.Net开发以来,最先接触的Web开发框架是Asp.Net WebForm,该框架高度封装,为了隐藏Http的无状态 ...

  3. [原创.数据可视化系列之三]使用Ol3加载大量点数据

    不管是百度地图还是高德地图,都很难得见到在地图上加载大量点要素,比如同屏1000的,因为这样客户端性能会很低,尤其是IE系列的浏览器,简直是卡的要死.但有的时候,还真的需要,比如,我要加载全球的AQI ...

  4. jsTree 的简单用法--异步加载和刷新数据

    首先这两个文件是必须要引用的,还有就是引用 jQuery 文件就不说了: <link href="/css/plugins/jsTree/style.min.css" rel ...

  5. 使用getJSON()方法异步加载JSON格式数据

    使用getJSON()方法异步加载JSON格式数据 使用getJSON()方法可以通过Ajax异步请求的方式,获取服务器中的数组,并对获取的数据进行解析,显示在页面中,它的调用格式为: jQuery. ...

  6. 异步加载回来的数据不受JS控制了

    写成下面这种方式时,异步加载回来的数据不受JS控制 $(."orderdiv").click(function(){ $(this).find(".orderinfo&q ...

  7. hive 压缩全解读(hive表存储格式以及外部表直接加载压缩格式数据);HADOOP存储数据压缩方案对比(LZO,gz,ORC)

    数据做压缩和解压缩会增加CPU的开销,但可以最大程度的减少文件所需的磁盘空间和网络I/O的开销,所以最好对那些I/O密集型的作业使用数据压缩,cpu密集型,使用压缩反而会降低性能. 而hive中间结果 ...

  8. echarts 图表重新加载,原来的数据依然存在图表上

    问题 在做一个全国地图上一些饼图,并且向省一级的地图钻取的时候,原来的饼图依然显示 原因 echars所有添加的图表都在一个series属性集合中,并且同一个echars对象默认是合并之前的数据的,所 ...

  9. mxnet自定义dataloader加载自己的数据

    实际上关于pytorch加载自己的数据之前有写过一篇博客,但是最近接触了mxnet,发现关于这方面的教程很少 如果要加载自己定义的数据的话,看mxnet关于mnist基本上能够推测12 看pytorc ...

随机推荐

  1. Python导入其他文件中的.py文件 即模块

    import sys sys.path.append("路径") import .py文件

  2. {"errcode":40097,"errmsg":"invalid args hint: [vjNe7xxxxxx8vr19]"}——记录一次微信错误处理

    错误情况概述: 启动应用之后,微信调用 相机拍照 等接口是可以正常使用的, 但是过了一段时间(2个小时左右--token/jsapi_ticket的过期时间),微信调用相机拍照的功能失效,启用debu ...

  3. Oracle学习笔记十二 子程序(存储过程、自定函数)和程序包

    子程序 子程序:命名的 PL/SQL 块,编译并存储在数据库中.   子程序的各个部分: 1.声明部分 2.可执行部分 3.异常处理部分(可选) 子程序的分类: 1.过程 - 执行某些操作 2.函数 ...

  4. 【推荐】CentOS安装PHP-5.6.4+扩展安装+安全配置+性能配置

    注:以下所有操作均在CentOS 6.5 x86_64位系统下完成. #准备工作# 前段时间PHP官方发布了一个重要的安全升级公告,修复了两个unserialize函数的严重漏洞,目前受影响的版本有: ...

  5. linux文件系统体系结构 和 虚拟文件系统(VFS)

    图 1. Linux 文件系统组件的体系结构 用户空间包含一些应用程序(例如,文件系统的使用者)和 GNU C 库(glibc),它们为文件系统调用(打开.读取.写和关闭)提供用户接口.系统调用接口的 ...

  6. 基于UDP的网络编程

    与TCP编程相比较,UDP缺少了connect().listen()及accept()函数,这是由于UDP协议无连接的特性,不用维护TCP的连接.断开等状态. UDP编程框图 API函数 socket ...

  7. Appium+python的一个简单完整的用例

    最近一直在忙,终于有时间来整理一下,传一个简单的用例,运行之后可以看到用例的报告,希望对大家有帮助. HTMLTestRunner这个包网上有很多,大家可以自己下载. 1 import unittes ...

  8. AutoMapper的使用

    1.AutoMapper简单介绍 官网:http://automapper.org/ 源码:https://github.com/AutoMapper/AutoMapper NUGET安装: PM&g ...

  9. [LeetCode] Repeated Substring Pattern 重复子字符串模式

    Given a non-empty string check if it can be constructed by taking a substring of it and appending mu ...

  10. 在WPF程序中打开网页:使用代理服务器并可进行JS交互

    本项目环境:使用VS2010(C#)编写的WPF程序,通过CefSharp在程序的窗体中打开网页.需要能够实现网页后台JS代码中调用的方法,从网页接收数据,并能返回数据给网页.运行程序的电脑不允许上网 ...