适用于iOS6之后的苹果提供的下拉刷新
一: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之后的苹果提供的下拉刷新的更多相关文章
- google官方提供的下拉刷新控件SwipeRefreshLayout
摘自:http://www.stormzhang.com/android/2014/03/29/android-swiperefreshlayout/ SwipeRefreshLayout Swipe ...
- Android官方提供的下拉刷新控件——SwipeRefreshLayout
<?xml version="1.0" encoding="utf-8"?> <RelativeLayout xmlns:android=&q ...
- Android开发学习之路-下拉刷新怎么做?
因为最近的开发涉及到了网络读取数据,那么自然少不了的就是下拉刷新的功能,搜索的方法一般是自己去自定义ListView或者RecyclerView来重写OnTouch或者OnScroll方法来实现手势的 ...
- AlloyTouch实现下拉刷新
原文地址:https://github.com/AlloyTeam/AlloyTouch/wiki/Pull-to-refresh 效果展示 扫码体验 你也可以点击这里访问Demo 可以点击这里查看代 ...
- google官方的下拉刷新+自定义上拉加载更多
转载请标注转载:http://blog.csdn.net/oqihaogongyuan/article/details/50949118 google官方的下拉刷新+自定义上拉加载更多 现在很多app ...
- z-tree官方提供的下拉菜单案例
1.z-tree官方提供的下拉菜单案例 <!DOCTYPE html> <HTML> <HEAD> <TITLE> ZTREE DEMO - selec ...
- 打造通用的Android下拉刷新组件(适用于ListView、GridView等各类View)
前言 近期在做项目时,使用了一个开源的下拉刷新ListView组件.极其的不稳定,bug还多.稳定的组件又写得太复杂了,jar包较大.在我的一篇博客中也讲述过下拉刷新的实现,即Android打造(Li ...
- Android 下拉刷新框架实现
原文地址:http://blog.csdn.net/leehong2005/article/details/12567757 前段时间项目中用到了下拉刷新功能,之前在网上也找到过类似的demo,但这些 ...
- Android-PullToRefresh下拉刷新库基本用法
How:(使用) 转自:http://blog.csdn.net/hantangsongming/article/details/42490277 PullToRefresh是一套实现非常好的下拉刷新 ...
随机推荐
- (4) go 运算符
1. (1) 整数相除,结果是小数,会舍去小数部分 (2) 使用自增自减时, ++ -- 必须单独一行 (3)只有后 a++,没有前 ++a 2. 3. 4. 5 6. 7. 8.
- 只安装自己需要的Office2016组件的方法
转自:https://www.ithome.com/html/office/178814.htm http://www.orsoon.com/news/184524.html
- 160. Intersection of Two Linked Lists【Easy】【求两个单链表的第一个交点】
Write a program to find the node at which the intersection of two singly linked lists begins. For ex ...
- 【计算几何】【圆反演】hdu6097 Mindis
给你一个中心在原点的圆,再给你俩在圆内且到原点距离相等的点P,Q,让你在圆上求一点D,最小化DP+DQ. http://blog.csdn.net/qq_34845082/article/detail ...
- JDK源码学习笔记——Iterable/Iterator实现原理
Collection接口继承java.lang.Iterable接口,集合类重写了iterator()方法 public interface Iterable<T> { Iterator& ...
- keytool工具生成自签名证书并且通过浏览器导入证书
1.生成服务器证书库 keytool -genkey -alias tomcat -keypass changeit -keyalg RSA -keysize 1024 -validity 365 - ...
- 修改ORACLE实例名
修改数据库的SID 举例说明,我的数据库的SID叫testdb,现在要改成oral.更改ORACLE数据库的sid,涉及到的用东西比较多,但是大概来说就以下六步. 1.停止所有的Oracle服务. ...
- Mac下JAVA开发环境搭建
最近开始学习JAVA, 首先配置下环境! 1.Mac自带的jdk版本老了,需要到oracle官网去下载新的jdk,具体下载那个版本看个人需求,然后安装. 安装完成之后打开Terminal, 执行命 ...
- CentOS 6.9下KVM虚拟机通过virt-clone克隆虚拟机(转)
一.virt-clone概述 1.virt-clone作用简介 virt-clone主要是用来克隆kvm虚拟机,并且通过Options.General Option.Storage Configura ...
- vs2017 新建Class 文件时,自动添加作者版权声明注释
1.用文本打开,在其头部加上 “C:\Program Files (x86)\Microsoft Visual Studio\2017\Enterprise\Common7\IDE\ItemTempl ...