CodingNet - Learning - 9
来源:互联网 发布:python爬虫源代码 编辑:程序博客网 时间:2024/06/01 23:19
我们继续到下一个页面:
接下来聚焦到这个页面,首先从我们关心的TableView和Cell开始入手
Cell的界面实现没有什么难度。
用到一个轮子:SWTableViewCell , 可以实现删除的一个很好的效果
点击设置常用,添加了一个pin的效果是怎么实现的呢?
刚开始想了很久,想过直接在ImageView上添加绘图的badgeView,或者甚至请求服务器返回哈哈,让服务器帮你添加
不过实现却是比较普通的,在ContentView上添加一个badgeView
[self.contentView addBadgeTip:badgeTip withCenterPosition:CGPointMake(10+kProjectListCell_IconHeight, 15)];
接下来我们从刷新的角度来剖析实现:
首先下拉刷新用到的几个三方库:
SVPullToRefresh
ODRefreshControl
分别有三个行为会调起刷新的行为:
1.点击tabBarItems项
2.下拉tableView
3.从别视图控制器回到该视图控制器
1.点击tabBarItems项:
记得前面的基类控制器:BaseViewController 的方法:
- (void)tabBarItemClicked;而在Project_RootViewController中我们重写这个方法:
- (void)tabBarItemClicked{ [super tabBarItemClicked]; if (_myCarousel.currentItemView && [_myCarousel.currentItemView isKindOfClass:[ProjectListView class]]) { ProjectListView *listView = (ProjectListView *)_myCarousel.currentItemView; [listView tabBarItemClicked]; }}
在ProjectListView 实现:
- (void)tabBarItemClicked{ if (_myTableView.contentOffset.y > 0) { [_myTableView setContentOffset:CGPointZero animated:YES]; }else if (!self.myRefreshControl.isAnimating){ [self.myRefreshControl beginRefreshing]; [self.myTableView setContentOffset:CGPointMake(0, -44)]; [self refresh]; }}
这样逐层传递这样就可以调用刷新方法了
第二三的方法就不多说了,就是简单的调用和适当嵌套
而我们要讲的是,这么多个刷新方法,都调用到同一个操作,sendRequest:
- (void)refreshUI{ [_myTableView reloadData]; [self refreshFirst];}- (void)refreshToQueryData{ [self refresh];}- (void)refresh{// _statusView.hidden=TRUE; NSString *headerTitle=[self getSectionHeaderName]; if (headerTitle.length>0) { self.noticeLab.text=headerTitle; self.statusView.hidden=FALSE; } if (_myProjects.isLoading) { return; } [self sendRequest];}- (void)refreshFirst{ if (_myProjects && !_myProjects.list) { [self performSelector:@selector(refresh) withObject:nil afterDelay:0.3]; }}- (void)refreshMore{ if (_myProjects.isLoading || !_myProjects.canLoadMore) { [_myTableView.infiniteScrollingView stopAnimating]; return; } _myProjects.willLoadMore = YES; [self sendRequest];}
最重要的如何理解这个sendRequest做了什么,不妨现在网络可用的情况下操作三种刷新,并输出后台,然后在网络不可用的情况下刷新并输出后台。可以看到,每一次刷新都要请求服务器,所以还是最重要的部分在网络库的封装是否合理,高效。
而网络库的封装是否合理在于和本地缓存的实现方案是否严谨,高效!
0 0
- CodingNet - Learning - 9
- CodingNet - Learning - 0
- CodingNet - Learning - 1
- CodingNet - Learning - 2
- CodingNet - Learning - 3
- CodingNet - Learning - 4
- CodingNet - Learning - 5
- CodingNet - Learning - 6
- CodingNet - Learning - 7
- CodingNet - Learning - 8
- CodingNet - Learning - 10
- CodingNet - Learning - 11
- CodingNet - Learning - 12
- CodingNet - Learning - 13
- CodingNet - Learning - 14
- CodingNet - Learning - 15
- CodingNet - Learning - 16
- CodingNet - Learning - 17
- 将博客搬至CSDN
- JQuery应用笔记【持续更新】
- Extjs 开发笔记【持续更新】
- android平移动画闪烁问题
- 定制6410开发板的linux最小内核/文件系统
- CodingNet - Learning - 9
- iis7错误0x80005000
- 大话设计模式-第13章 好菜每回味不同--建造者模式
- Java - Java概述
- 正则表达式:检查一个句子或者字符串是否以大写字母开头,以句号结尾.
- JavaScript---网络编程(7)-Dom模型(节点间的层次关系,节点的增、删、改)
- android手机App的开发——音乐播放器
- Swift之GCD 使用指南2
- 《python算法笔记》(一)为什么要学习算法