iOS-SVPullToRefresh下拉刷新,上拉加载(转)
https://github.com/Sephiroth87/ODRefreshControl 类似刷新控件,类似qq动画的那种刷新。
一.下载第三方库
https://github.com/samvermette/SVPullToRefresh
二.使用方法
1.导入下载的第三方库
2.导入头文件
在需要的类里导入这一个头文件就能,同时使用下拉刷新,上拉加载
#import "SVPullToRefresh.h"
3.下拉刷新
- [_tableView addPullToRefreshWithActionHandler:^{
- //数据的加载,和表的刷新的代码。
- //全部需要我们自己写
- // [self refreshTableView];
- //3秒后调用refreshTableView方法
- [self performSelector:@selector(refreshTableView) withObject:nil afterDelay:1.0];
- // //风火轮的动画还需要我们手动的停止
- // [_tableView.pullToRefreshView stopAnimating];
- }];
4.上拉加载
- [_tableView addInfiniteScrollingWithActionHandler:^{
- [self performSelector:@selector(insertDate) withObject:nil afterDelay:3.0];
- }];
5.自定义显示的文字
- [_tableView.pullToRefreshView setTitle:@"下拉以刷新" forState:SVPullToRefreshStateTriggered];
- [_tableView.pullToRefreshView setTitle:@"刷新完了呀" forState:SVPullToRefreshStateStopped];
- [_tableView.pullToRefreshView setTitle:@"不要命的加载中..." forState:SVPullToRefreshStateLoading];
6.自定义刷新时的动画
- UIView* view = [[UIView alloc] initWithFrame:CGRectMake(0, 0, 200, 40)];
- view.backgroundColor = [UIColor blueColor];
- [UIView beginAnimations:nil context:nil];
- [UIView setAnimationDuration:3];
- view.alpha = 0.5 ;
- [UIView commitAnimations];
- [_tableView.pullToRefreshView setCustomView:view forState:SVPullToRefreshStateAll];
当然可以把view换成imageView等控件实现动画效果
7.实现刷新和加载的两个方法
- - (void)refreshTableView
- {
- }
- - (void)insertDate
- {
- }
三.注意事项
iOS7和我们的下拉刷新库有冲突,因为都是对contentOffset进行操作,解决冲突,有两种做法
方法1:禁用navgationbar的半透明效果,还原至iOS6中的效果
- self.navigationController.navigationBar.translucent = NO;
方法2:禁止系统自己修改contentOffset,然后修改tableView的frame
automaticallyAdjustsScrollViewInsets 这个属性,只有iOS7以后才能用,所以如果要兼容iOS6,在iOS6运行,我们需要判断一下能不能使用这个属性或者当前的系统版本
最终代码为:
- if ([[UIDevice currentDevice].systemVersion floatValue] >= 7.0)
- {
- self.automaticallyAdjustsScrollViewInsets = NO;
- _tableView.frame = CGRectMake(0, 64, 320, self.view.bounds.size.height - 64);
- };
iOS-SVPullToRefresh下拉刷新,上拉加载(转)的更多相关文章
- Android 下拉刷新上啦加载SmartRefreshLayout + RecyclerView
在弄android刷新的时候,可算是耗费了一番功夫,最后发觉有现成的控件,并且非常好用,这里记录一下. 原文是 https://blog.csdn.net/huangxin112/article/de ...
- SwipeRefreshLayout实现下拉刷新上滑加载
1. 效果图 2.RefreshLayout.java package myapplication.com.myapplication; import android.content.Context; ...
- 移动端下拉刷新上拉加载-mescroll.js插件
最近无意间看到有这么一个上拉刷新下拉加载的插件 -- mescroll.js,个人感觉挺好用的,官网地址是:http://www.mescroll.com 然后我就看了一下文档,简单的写了一个小dem ...
- 带你实现开发者头条APP(五)--RecyclerView下拉刷新上拉加载
title: 带你实现开发者头条APP(五)--RecyclerView下拉刷新上拉加载 tags: -RecyclerView,下拉刷新,上拉加载更多 grammar_cjkRuby: true - ...
- ListView实现Item上下拖动交换位置 并且实现下拉刷新 上拉加载更多
ListView实现Item上下拖动交换位置 并且实现下拉刷新 上拉加载更多 package com.example.ListViewDragItem; import android.app.Ac ...
- [ionic开源项目教程] - 第7讲 实现下拉刷新上拉加载ion-refresher和ion-infinite-scroll
第7讲 实现下拉刷新上拉加载ion-refresher和ion-infinite-scroll 1.将tab1.html的代码改为如下: <ion-content> <ion-ref ...
- JS+CSS实现的下拉刷新/上拉加载插件
闲来无事,写了一个当下比较常见的下拉刷新/上拉加载的jquery插件,代码记录在这里,有兴趣将代码写成插件与npm包可以留言. 体验地址:http://owenliang.github.io/pull ...
- 基于SwiperJs的H5/移动端下拉刷新上拉加载更多的效果
最早时,公司的H5项目中曾用过点击一个"加载更多"的DOM元素来实现分页的功能,后来又用过网上有人写的一个上拉加载更多的插件,那个插件是页面将要滚动到底部时就自动请求数据并插入到页 ...
- ListView下拉刷新上拉加载更多实现
这篇文章将带大家了解listview下拉刷新和上拉加载更多的实现过程,先看效果(注:图片中listview中的阴影可以加上属性android:fadingEdge="none"去掉 ...
- RecyclerView下拉刷新上拉加载(三)—对Adapter的封装
RecyclerView下拉刷新上拉加载(一) http://blog.csdn.net/baiyuliang2013/article/details/51506036 RecyclerView下拉刷 ...
随机推荐
- springboot中,使用redisTemplate操作redis
知识点: springboot中整合redis springboot中redisTemplate的使用 redis存数据时,key出现乱码问题 一:springboot中整合redis (1)pom. ...
- Java基础 String 裸暴力算法- 五个小练习
之间的博客,承上启下: Java基础 String/StringBuff 常用操作方法复习/内存分析 Java数组直接选择排序.sort()排序 Java基础 String 算法 - 五个练 ...
- JS中constructor,prototype
First: this this定义: this就是函数赖以执行的对象. 分析这句话: 1. this是对象. 2. this依赖函数执行的上下文环境. 3. this存在函数中. 直接看例子: al ...
- Java并发包--ConcurrentLinkedQueue
转载请注明出处:http://www.cnblogs.com/skywang12345/p/3498995.html ConcurrentLinkedQueue介绍 ConcurrentLinkedQ ...
- 将CHROME WEBSTORE里的APPS和扩展下载到本地 转载自:http://ro-oo.diandian.com/post/2011-05-28/1103036
Chrome Webstore 自动改版后就不能再直接下载到本地... 下载地址: https://clients2.google.com/service/update2/crx?response=r ...
- position:absolute 按钮左右分布:left:0 和 right:0 以及雪碧图
问题:把两个a标签按钮 垂直居中,并且分别把两个按钮放在水平左右两边顶部1,祖父元素设定:position:relative2,把.arrow 设定上下垂直居中 position:absolute; ...
- soapui如何发送xml格式的字符串
一个服务需要的xml格式的字符串参数,用soapUI传递参数时要这样写: <![CDATA[<?xml version="1.0" encoding="UTF ...
- MySQL 源码编译安装脚本
cat mysql_init.shmysql_init.sh mysql_init.sh.20190401 mysql_init.sh.back20171030 ...
- learning express step(十三)
learning express error handle code: const express = require('express'); const app = express(); app.g ...
- docker 1.12
curl https://releases.rancher.com/install-docker/1.12.sh | sh http://rancher.com/docs/rancher/v1.6/e ...