新浪微博客户端(18)-集成下拉刷新控件UIRefreshControl
HomeViewController.m
- - (void)setupPullToRefreshView {
- UIRefreshControl *refreshControl = [[UIRefreshControl alloc] init];
- [refreshControl addTarget:self action:@selector(refreshNewData:) forControlEvents:UIControlEventValueChanged];
- [self.tableView addSubview:refreshControl];
- }
- #pragma mark - UIRefreshContorl 监听方法
- - (void)refreshNewData:(UIRefreshControl *)control {
- AFHTTPSessionManager *requestManager = [AFHTTPSessionManager manager];
- NSString *urlString = @"https://api.weibo.com/2/statuses/friends_timeline.json";
- NSMutableDictionary *params = [NSMutableDictionary dictionary];
- params[@"access_token"] = [DJAccountTool account].access_token;
- DJStatus *status = [self.statuses firstObject];
- if (status) {
- params[@"since_id"] = status.idstr;
- }
- [requestManager GET:urlString parameters:params progress:nil success:^(NSURLSessionDataTask * _Nonnull task, NSDictionary * _Nullable responseObject) {
- NSArray *newStatuses = [DJStatus mj_objectArrayWithKeyValuesArray:responseObject[@"statuses"]];
- // 将刷新获取到的新数据添加到总数组的头部
- NSRange range = NSMakeRange(, newStatuses.count);
- NSIndexSet *indexSet = [[NSIndexSet alloc] initWithIndexesInRange:range];
- [self.statuses insertObjects:newStatuses atIndexes:indexSet];
- // 刷新TableView
- [self.tableView reloadData];
- // 隐藏RefreshControl
- [control endRefreshing];
- } failure:^(NSURLSessionDataTask * _Nullable task, NSError * _Nonnull error) {
- [control endRefreshing]; // 当数据获取失败时结束刷新操作
- }];
- }
最终效果:
新浪微博客户端(18)-集成下拉刷新控件UIRefreshControl的更多相关文章
- iOS:下拉刷新控件UIRefreshControl的详解
下拉刷新控件:UIRefreshControl 1.具体类信息: @interface UIRefreshControl : UIControl //继承控制类 - (instancetype)ini ...
- IOS6.0自带下拉刷新控件UIRefreshControl
1.UIRefreshControl必需要在IOS6.0以后才干使用,同一时候他仅仅能在UITableViewController类中才干够使用 2.使用比較简单 self.refreshContro ...
- Android——谷歌官方下拉刷新控件SwipeRefreshLayout(转)
转自:http://blog.csdn.net/zouzhigang96/article/details/50476402 版权声明:本文为博主原创文章,未经博主允许不得转载. 前言: 如今谷歌推出了 ...
- android官方下拉刷新控件SwipeRefreshLayout的使用
可能开发安卓的人大多数都用过很多下拉刷新的开源组件,但是今天用了官方v4支持包的SwipeRefreshLayout觉得效果也蛮不错的,特拿出来分享. 简介:SwipeRefreshLayout组件只 ...
- [Android]下拉刷新控件RefreshableView的实现
以下内容为原创,欢迎转载,转载请注明 来自天天博客:http://www.cnblogs.com/tiantianbyconan/p/4172483.html 需求:自定义一个ViewGroup,实现 ...
- android SwipeRefreshLayout google官方下拉刷新控件
下拉刷新功能之前一直使用的是XlistView很方便我前面的博客有介绍 SwipeRefreshLayout是google官方推出的下拉刷新控件使用方法也比较简单 今天就来使用下SwipeRefres ...
- Android PullToRefresh下拉刷新控件的简单使用
PullToRefresh这个开源库早就听说了,不过一直没用过.作为一个经典的的开源库,我觉得还是有必要认识一下. 打开github上的网址:https://github.com/chrisbanes ...
- Android SwipeRefreshLayout 官方下拉刷新控件介绍
转载请标明出处:http://blog.csdn.net/lmj623565791/article/details/24521483 下面App基本都有下拉刷新的功能,以前基本都使用XListView ...
- Google SwipeRefreshLayout(Goolge官方下拉刷新控件)尝鲜
前天Google官方终于出了Android刷新控件——SwipeRefreshLayout. 使用前先需要将android.support.v4.jar升级到19.1.升级后,可能会出现SDK版本与A ...
随机推荐
- 【插件开发】—— 1 Eclipse插件开发导盲
[插件开发]—— 1 Eclipse插件开发导盲 在真正接触eclipse插件开发一个月后,对插件的开发过程以及技术要求,也有了一定的了解.遥想之前像无头苍蝇一样乱撞乱学,真心觉得浪费了不少时间. ...
- HoloToolkit项目源码剖析 - Spatial Mapping功能实现
就像我之前所描述的,HoloToolkit项目是微软基于Unity内置的底层API封装的一套工具集合,帮助我们快速使用Unity集成开发HoloLens应用. 本文主要通过源码研究其中Spatial ...
- protobuf 文件级别优化
package IM.BaseDefine;option java_package = "com.mogujie.tt.protobuf";option optimize_for ...
- 从零开始写redis客户端(deerlet-redis-client)之路——第一个纠结很久的问题,restore引发的血案
引言 正如之前的一篇博文,LZ最近正在从零开始写一个redis的客户端,主要目的是为了更加深入的了解redis,当然了,LZ也希望deerlet客户端有一天能有一席之地.在写的过程当中,LZ遇到了一个 ...
- Scala 中的函数式编程基础(一)
主要来自 Scala 语言发明人 Martin Odersky 教授的 Coursera 课程 <Functional Programming Principles in Scala>. ...
- [Aaronyang] 写给自己的WPF4.5 失传的第一本古老秘籍[多扩展显示器编程]
世界上只有想不通的人,没有走不通的路 --Aaronyang的博客(www.ayjs.net)-www.8mi.me =============时隔两年后再看WPF,有些秘籍不太适合公开,公开了就不值 ...
- JavaScript表单处理(上)
为了分担服务器处理表单的压力,JavaScript提供了一些解决方案,从而大大打破了处处依赖服务器的局面. 发文不易,转载请亲注明出处,谢谢! 一.表单介绍 在HTML中,表单是由<form& ...
- BootStrap网格布局
如何使用BootStrap样式 BootStrap与其他的开源库类似,直接引用它的css样式文件就可以使用了. <link rel="stylesheet" href=&qu ...
- Daily Scrum – 1/5
Meeting Minutes 开始了新的sprint: 开始准备英语版本的翻译: Progress part 组员 今日工作 Time (h) 明日计划 Time (h) Wei ...
- Codeforces Beta Round #6 (Div. 2 Only) D. Lizards and Basements 2 dp
题目链接: http://codeforces.com/problemset/problem/6/D D. Lizards and Basements 2 time limit per test2 s ...