一:iOS6.0及以后:

  • 下拉刷新控件UIRefreshControl
  • TableView属性:refreshControl

二:使用

 - (void)colseTheTB
{
[self dismissViewControllerAnimated:YES completion:nil];
} - (void)viewDidLoad
{
[super viewDidLoad]; self.navigationItem.leftBarButtonItem = [[UIBarButtonItem alloc]initWithBarButtonSystemItem:UIBarButtonItemStylePlain target:self action:@selector(colseTheTB)]; //数据源
self.dataArray = [[NSMutableArray alloc]initWithCapacity:];
for (int i = ; i < ; i ++) {
[_dataArray addObject:[NSString stringWithFormat:@"%d",i]];
} //适用于 iOS6 之后,系统自带的下拉刷新控件 UIRefreshControl
UIRefreshControl *osRefresh = [[UIRefreshControl alloc]init];
osRefresh.tintColor = [UIColor lightGrayColor];
osRefresh.attributedTitle = [[NSAttributedString alloc]initWithString:@"下拉刷新"];
[osRefresh addTarget:self action:@selector(doPullRefresh:) forControlEvents:UIControlEventValueChanged];
self.refreshControl = osRefresh; } - (void)doPullRefresh:(UIRefreshControl *)refresh
{
if (refresh.refreshing) {
refresh.attributedTitle = [[NSAttributedString alloc]initWithString:@"正在刷新"];
[self performSelector:@selector(handleTheRefresh) withObject:nil afterDelay:];
} else
{
refresh.attributedTitle = [[NSAttributedString alloc]initWithString:@"释放刷新"]; }
} - (void)handleTheRefresh
{
NSDateFormatter *formatter = [[NSDateFormatter alloc] init];
[formatter setDateFormat:@"MMM d, h:mm:ss a"];
NSString *lastUpdated = [NSString stringWithFormat:@"时间:%@", [formatter stringFromDate:[NSDate date]]];
self.refreshControl.attributedTitle = [[NSAttributedString alloc] initWithString:lastUpdated] ; static int num = ;
num--;
[_dataArray insertObject:[NSString stringWithFormat:@"%d",num] atIndex:]; [self.refreshControl endRefreshing];
[self.tableView reloadData];
}

三:显示情况

  • 在iOS6上显示情况,请参见 qq for iPhone版本 app
  • 在iOS7 显示情况,是菊花动画,一片一片的铺满

适用于iOS6之后的苹果提供的下拉刷新的更多相关文章

  1. google官方提供的下拉刷新控件SwipeRefreshLayout

    摘自:http://www.stormzhang.com/android/2014/03/29/android-swiperefreshlayout/ SwipeRefreshLayout Swipe ...

  2. Android官方提供的下拉刷新控件——SwipeRefreshLayout

    <?xml version="1.0" encoding="utf-8"?> <RelativeLayout xmlns:android=&q ...

  3. Android开发学习之路-下拉刷新怎么做?

    因为最近的开发涉及到了网络读取数据,那么自然少不了的就是下拉刷新的功能,搜索的方法一般是自己去自定义ListView或者RecyclerView来重写OnTouch或者OnScroll方法来实现手势的 ...

  4. AlloyTouch实现下拉刷新

    原文地址:https://github.com/AlloyTeam/AlloyTouch/wiki/Pull-to-refresh 效果展示 扫码体验 你也可以点击这里访问Demo 可以点击这里查看代 ...

  5. google官方的下拉刷新+自定义上拉加载更多

    转载请标注转载:http://blog.csdn.net/oqihaogongyuan/article/details/50949118 google官方的下拉刷新+自定义上拉加载更多 现在很多app ...

  6. z-tree官方提供的下拉菜单案例

    1.z-tree官方提供的下拉菜单案例 <!DOCTYPE html> <HTML> <HEAD> <TITLE> ZTREE DEMO - selec ...

  7. 打造通用的Android下拉刷新组件(适用于ListView、GridView等各类View)

    前言 近期在做项目时,使用了一个开源的下拉刷新ListView组件.极其的不稳定,bug还多.稳定的组件又写得太复杂了,jar包较大.在我的一篇博客中也讲述过下拉刷新的实现,即Android打造(Li ...

  8. Android 下拉刷新框架实现

    原文地址:http://blog.csdn.net/leehong2005/article/details/12567757 前段时间项目中用到了下拉刷新功能,之前在网上也找到过类似的demo,但这些 ...

  9. Android-PullToRefresh下拉刷新库基本用法

    How:(使用) 转自:http://blog.csdn.net/hantangsongming/article/details/42490277 PullToRefresh是一套实现非常好的下拉刷新 ...

随机推荐

  1. 《深入理解Android2》读书笔记(一)

    2017-5-12 从今天开始估计有一段空闲时间,开始阅读<深入理解Android2>,并写读书笔记. 第一章搭建环境直接略过. 第二章是Binder,暂时略过 7大类服务包括:1.And ...

  2. 总结分析Java常见的四种引用

    从JDK1.2版本开始,把对象的引用分为四种级别,从而使程序能更加灵活的控制对象的生命周期.这四种级别由高到低依次为:强引用.软引用.弱引用和虚引用. 1.强引用 本章前文介绍的引用实际上都是强引用, ...

  3. 【最短路径】 SPFA算法

    上一期介绍到了SPFA算法,只是一笔带过,这一期让我们详细的介绍一下SPFA. 1 SPFA原理介绍 SPFA算法和dijkstra算法特别像,总感觉自己讲的不行,同学说我的博客很辣鸡,推荐一个视频讲 ...

  4. 【KMP】BZOJ3942-[Usaco2015 Feb] Censoring

    [题目大意] 有一个S串和一个T串,长度均小于1,000,000,设当前串为U串,然后从前往后枚举S串一个字符一个字符往U串里添加,若U串后缀为T,则去掉这个后缀继续流程.输出最后的S串. [思路]三 ...

  5. 【LCA】BZOJ1832 & BZOJ1787(AHOI)-集会

    [题目大意] 一个图有n个点n-1条边(也就是说是一棵树),求其中三点共同到达某一点经过总共的最少边数以及共同到达的那一点. [思路] 借用一下黄学长给的结论:三个点两两取LCA,其中必有两个相同,则 ...

  6. 20162303实验三 敏捷开发与XP实践-1

    北京电子科技学院(BESTI) 实 验 报 告 课程:程序设计与数据结构 班级: 1623 姓名: 石亚鑫 学号:20162303 成绩: 2分 指导教师:娄嘉鹏 王志强 实验日期:5月12日 实验密 ...

  7. 推荐系统中的SVD

    本文主要参考:Factorization Meets the Neighborhood: a Multifaceted Collaborative Filtering Model 在用户对自己需求相对 ...

  8. appium+python自动化45-夜神模拟器连不上(adb server version (36) doesn't match this client (39); killing...)

    前言 最新下了个最新版的夜神模拟器,然后adb devices发现连不上模拟器了,报adb server version (36) doesn't match this client (39); ki ...

  9. iOS中nil、Nil、NULL、NSNull详解

    nil nil 是 ObjC 对象的字面空值,对应 id 类型的对象,或者使用 @interface 声明的 ObjC 对象. 例如: NSString *someString = nil; NSUR ...

  10. websocket+golang聊天室

    原文地址: http://www.niu12.com/article/3 websocket+golang聊天室 main.go和index.html放在同一目录下 main.go package m ...