https://github.com/Sephiroth87/ODRefreshControl 类似刷新控件,类似qq动画的那种刷新。

一.下载第三方库

https://github.com/samvermette/SVPullToRefresh

二.使用方法

1.导入下载的第三方库

2.导入头文件

在需要的类里导入这一个头文件就能,同时使用下拉刷新,上拉加载

#import "SVPullToRefresh.h"

3.下拉刷新

  1. [_tableView addPullToRefreshWithActionHandler:^{
  2. //数据的加载,和表的刷新的代码。
  3. //全部需要我们自己写
  4. //        [self refreshTableView];
  5. //3秒后调用refreshTableView方法
  6. [self performSelector:@selector(refreshTableView) withObject:nil afterDelay:1.0];
  7. //        //风火轮的动画还需要我们手动的停止
  8. //        [_tableView.pullToRefreshView stopAnimating];
  9. }];

4.上拉加载

  1. [_tableView addInfiniteScrollingWithActionHandler:^{
  2. [self performSelector:@selector(insertDate) withObject:nil afterDelay:3.0];
  3. }];

5.自定义显示的文字

  1. [_tableView.pullToRefreshView setTitle:@"下拉以刷新" forState:SVPullToRefreshStateTriggered];
  2. [_tableView.pullToRefreshView setTitle:@"刷新完了呀" forState:SVPullToRefreshStateStopped];
  3. [_tableView.pullToRefreshView setTitle:@"不要命的加载中..." forState:SVPullToRefreshStateLoading];

6.自定义刷新时的动画

  1. UIView* view = [[UIView alloc] initWithFrame:CGRectMake(0, 0, 200, 40)];
  2. view.backgroundColor = [UIColor blueColor];
  3. [UIView beginAnimations:nil context:nil];
  4. [UIView setAnimationDuration:3];
  5. view.alpha = 0.5 ;
  6. [UIView commitAnimations];
  7. [_tableView.pullToRefreshView setCustomView:view forState:SVPullToRefreshStateAll];

当然可以把view换成imageView等控件实现动画效果
7.实现刷新和加载的两个方法

  1. - (void)refreshTableView
  2. {
  3. }
  4. - (void)insertDate
  5. {
  6. }

三.注意事项

iOS7和我们的下拉刷新库有冲突,因为都是对contentOffset进行操作,解决冲突,有两种做法

方法1:禁用navgationbar的半透明效果,还原至iOS6中的效果

  1. self.navigationController.navigationBar.translucent = NO;

方法2:禁止系统自己修改contentOffset,然后修改tableView的frame

automaticallyAdjustsScrollViewInsets 这个属性,只有iOS7以后才能用,所以如果要兼容iOS6,在iOS6运行,我们需要判断一下能不能使用这个属性或者当前的系统版本

最终代码为:

  1. if ([[UIDevice currentDevice].systemVersion floatValue] >= 7.0)
    1. {
    2. self.automaticallyAdjustsScrollViewInsets = NO;
    3. _tableView.frame = CGRectMake(0, 64, 320, self.view.bounds.size.height - 64);
    4. };

iOS-SVPullToRefresh​下拉刷新,上拉加载(转)的更多相关文章

  1. Android 下拉刷新上啦加载SmartRefreshLayout + RecyclerView

    在弄android刷新的时候,可算是耗费了一番功夫,最后发觉有现成的控件,并且非常好用,这里记录一下. 原文是 https://blog.csdn.net/huangxin112/article/de ...

  2. SwipeRefreshLayout实现下拉刷新上滑加载

    1. 效果图 2.RefreshLayout.java package myapplication.com.myapplication; import android.content.Context; ...

  3. 移动端下拉刷新上拉加载-mescroll.js插件

    最近无意间看到有这么一个上拉刷新下拉加载的插件 -- mescroll.js,个人感觉挺好用的,官网地址是:http://www.mescroll.com 然后我就看了一下文档,简单的写了一个小dem ...

  4. 带你实现开发者头条APP(五)--RecyclerView下拉刷新上拉加载

    title: 带你实现开发者头条APP(五)--RecyclerView下拉刷新上拉加载 tags: -RecyclerView,下拉刷新,上拉加载更多 grammar_cjkRuby: true - ...

  5. ListView实现Item上下拖动交换位置 并且实现下拉刷新 上拉加载更多

    ListView实现Item上下拖动交换位置  并且实现下拉刷新  上拉加载更多 package com.example.ListViewDragItem; import android.app.Ac ...

  6. [ionic开源项目教程] - 第7讲 实现下拉刷新上拉加载ion-refresher和ion-infinite-scroll

    第7讲 实现下拉刷新上拉加载ion-refresher和ion-infinite-scroll 1.将tab1.html的代码改为如下: <ion-content> <ion-ref ...

  7. JS+CSS实现的下拉刷新/上拉加载插件

    闲来无事,写了一个当下比较常见的下拉刷新/上拉加载的jquery插件,代码记录在这里,有兴趣将代码写成插件与npm包可以留言. 体验地址:http://owenliang.github.io/pull ...

  8. 基于SwiperJs的H5/移动端下拉刷新上拉加载更多的效果

    最早时,公司的H5项目中曾用过点击一个"加载更多"的DOM元素来实现分页的功能,后来又用过网上有人写的一个上拉加载更多的插件,那个插件是页面将要滚动到底部时就自动请求数据并插入到页 ...

  9. ListView下拉刷新上拉加载更多实现

    这篇文章将带大家了解listview下拉刷新和上拉加载更多的实现过程,先看效果(注:图片中listview中的阴影可以加上属性android:fadingEdge="none"去掉 ...

  10. RecyclerView下拉刷新上拉加载(三)—对Adapter的封装

    RecyclerView下拉刷新上拉加载(一) http://blog.csdn.net/baiyuliang2013/article/details/51506036 RecyclerView下拉刷 ...

随机推荐

  1. springboot中,使用redisTemplate操作redis

    知识点: springboot中整合redis springboot中redisTemplate的使用 redis存数据时,key出现乱码问题 一:springboot中整合redis (1)pom. ...

  2. Java基础 String 裸暴力算法- 五个小练习

      之间的博客,承上启下:    Java基础 String/StringBuff 常用操作方法复习/内存分析 Java数组直接选择排序.sort()排序 Java基础 String 算法 - 五个练 ...

  3. JS中constructor,prototype

    First: this this定义: this就是函数赖以执行的对象. 分析这句话: 1. this是对象. 2. this依赖函数执行的上下文环境. 3. this存在函数中. 直接看例子: al ...

  4. Java并发包--ConcurrentLinkedQueue

    转载请注明出处:http://www.cnblogs.com/skywang12345/p/3498995.html ConcurrentLinkedQueue介绍 ConcurrentLinkedQ ...

  5. 将CHROME WEBSTORE里的APPS和扩展下载到本地 转载自:http://ro-oo.diandian.com/post/2011-05-28/1103036

    Chrome Webstore 自动改版后就不能再直接下载到本地... 下载地址: https://clients2.google.com/service/update2/crx?response=r ...

  6. position:absolute 按钮左右分布:left:0 和 right:0 以及雪碧图

    问题:把两个a标签按钮 垂直居中,并且分别把两个按钮放在水平左右两边顶部1,祖父元素设定:position:relative2,把.arrow 设定上下垂直居中 position:absolute; ...

  7. soapui如何发送xml格式的字符串

    一个服务需要的xml格式的字符串参数,用soapUI传递参数时要这样写: <![CDATA[<?xml version="1.0" encoding="UTF ...

  8. MySQL 源码编译安装脚本

    cat mysql_init.shmysql_init.sh               mysql_init.sh.20190401      mysql_init.sh.back20171030  ...

  9. learning express step(十三)

    learning express error handle code: const express = require('express'); const app = express(); app.g ...

  10. docker 1.12

    curl https://releases.rancher.com/install-docker/1.12.sh | sh http://rancher.com/docs/rancher/v1.6/e ...