想尝试拉加载意识到有多少开始了他的研究之旅,我看了两天做出最终的界面。

之所以这么慢是由于,我不知道要将上拉出现的view放在哪。就能在scrollView拉究竟部的时候被拉出来。还有就是怎么拉出来之后停在这里。网上下载样例之后研究了两天:

watermark/2/text/aHR0cDovL2Jsb2cuY3Nkbi5uZXQvdTAxMDEyMzIwOA==/font/5a6L5L2T/fontsize/400/fill/I0JBQkFCMA==/dissolve/70/gravity/SouthEast" alt="">

watermark/2/text/aHR0cDovL2Jsb2cuY3Nkbi5uZXQvdTAxMDEyMzIwOA==/font/5a6L5L2T/fontsize/400/fill/I0JBQkFCMA==/dissolve/70/gravity/SouthEast" alt="">

先说一下,在以下处理图片中橘色view的位置的时候用了kvo进行了监听。

先一个枚举 来指示眼下刷新view是在哪个状态:

typedef enum {
RefreshStateLoading = 1,//刷新状态为正在载入
RefreshStateRelease, //下拉完毕释放之前
RefreshStateNomal, //原始状态
}RefreshState;

以下一个类view来描写叙述刷新view

@interface FootView : UIView

@property (nonatomic,strong) UIActivityIndicatorView *activity;//活动指示条
@property (nonatomic,strong) UIImageView *imageView; //箭头图片
@property (nonatomic,strong) UILabel *infolabel; //文字指示
@property (nonatomic,assign) RefreshState refreshState; //刷新的状态 - (void)refreshStateLoading;
- (void)refreshStateNomal;
- (void)refreshStateRelsease; @end
#import "FootView.h"

@implementation FootView

@synthesize activity;
@synthesize imageView;
@synthesize infolabel;
@synthesize refreshState; - (id)initWithFrame:(CGRect)frame
{
self = [super initWithFrame:frame];
if (self) {
self.backgroundColor = [UIColor orangeColor]; //活动指示器初始化
activity = [[UIActivityIndicatorView alloc]initWithActivityIndicatorStyle:UIActivityIndicatorViewStyleGray];
activity.frame = CGRectMake(10, 0, 50, 70);
[self addSubview:activity]; //箭头图片初始化
imageView = [[UIImageView alloc]initWithFrame:CGRectMake(10, 10, 30, 50)];
imageView.image = [UIImage imageNamed:@"blackArrow.png"];
[self addSubview:imageView]; //信息label初始化
infolabel = [[UILabel alloc]initWithFrame:CGRectMake(100,0 ,100, 70)];
infolabel.text = @"下拉刷新...";
infolabel.font = [UIFont fontWithName:@"Helvetica" size:20];
infolabel.textAlignment = NSTextAlignmentCenter;
infolabel.textColor = [UIColor blackColor];
[self addSubview:infolabel]; //设置初始状态
self.refreshState = RefreshStateNomal;
}
return self;
} //初始状态
- (void)refreshStateNomal
{
self.refreshState = RefreshStateNomal;
[self.activity stopAnimating];
self.infolabel.text = @"下拉载入很多其它...";
self.imageView.layer.transform = CATransform3DMakeRotation(M_PI * 2, 0, 0, 1);
self.imageView.hidden = NO;
} //正在请求数据时
- (void)refreshStateLoading
{
self.refreshState = RefreshStateLoading;
self.imageView.hidden = YES;
[UIView beginAnimations:nil context:nil];
self.infolabel.text = @"正在载入...";
[self.activity startAnimating];
[UIView commitAnimations];
} //下拉完毕后
- (void)refreshStateRelsease
{
self.refreshState = RefreshStateRelease;
[UIView beginAnimations:nil context:nil];
self.infolabel.text = @"释放后载入...";
self.imageView.layer.transform = CATransform3DMakeRotation(M_PI, 0, 0, 1);
[UIView commitAnimations]; } @end

以下来写table

#import <UIKit/UIKit.h>

@interface MyTableVC : UITableViewController<UIScrollViewDelegate>

@property (nonatomic,strong) NSMutableArray *dataArray;//数据

@end
#import "MyTableVC.h"
#import "FootView.h" #define TABLE_CELL_HIGHT 50.0 @interface MyTableVC () @end @implementation MyTableVC
{
FootView *footView;
} @synthesize dataArray; - (id)initWithStyle:(UITableViewStyle)style
{
self = [super initWithStyle:style];
if (self) { }
return self;
} - (void)viewDidLoad
{
[super viewDidLoad];
dataArray = [NSMutableArray arrayWithArray:@[@"列表1",@"列表2",@"列表3",@"列表2",@"列表3",@"列表2",@"列表3",@"列表2",@"列表3",@"列表2",@"列表3",@"列表2",@"列表3",@"列表2",@"列表5"]];
[self addPullToRefreshFooter];
} //加入FootView指示器
- (void)addPullToRefreshFooter
{
//FootView初始化
footView = [[FootView alloc]initWithFrame:CGRectMake(0, dataArray.count*50 , 320, 251)];
[self.tableView addSubview:footView];
//监视数据数组
[self addObserver:self forKeyPath:@"dataArray" options:NSKeyValueObservingOptionNew context:nil];
} #pragma mark - Table view data source - (float)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath
{
return TABLE_CELL_HIGHT;
} - (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
{
return 1;
} - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
return dataArray.count;
} - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
static NSString *inditifierCell = @"Cell";
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:inditifierCell];
if (cell == nil) {
cell = [[UITableViewCell alloc]initWithStyle:UITableViewCellStyleDefault reuseIdentifier:inditifierCell];
}
cell.textLabel.text = [dataArray objectAtIndex:indexPath.row]; return cell;
} - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
NSMutableArray *new = [[NSMutableArray alloc]initWithArray:dataArray];
[new addObject:@"张三"];
self.dataArray = new;
[footView refreshStateNomal];
self.tableView.contentInset = UIEdgeInsetsMake(0, 0, 0, 0); } #pragma mark - kvo
//用于监听dataArray数组来设置footview的位置
- (void) observeValueForKeyPath:(NSString *)keyPath ofObject:(id)object change:(NSDictionary *)change context:(void *)context
{
NSLog(@"%d",dataArray.count);
NSMutableArray *mutableArray = [change objectForKey:@"new"];
footView.frame = CGRectMake(0,TABLE_CELL_HIGHT* mutableArray.count, 320, 251);
[self.tableView reloadData];
} #pragma mark - Scroller //当scroller滑动时调用
- (void) scrollViewDidScroll:(UIScrollView *)scrollView
{
if (footView.refreshState == RefreshStateNomal&& scrollView.contentOffset.y > scrollView.contentSize.height - scrollView.frame.size.height + 70) {
[footView refreshStateRelsease];
}
} //当滑动结束时调用
- (void)scrollViewDidEndDragging:(UIScrollView *)scrollView willDecelerate:(BOOL)decelerate
{
if (footView.refreshState == RefreshStateRelease) {
[UIView beginAnimations:nil context:nil];
self.tableView.contentInset = UIEdgeInsetsMake(0, 0, 70, 0);
[footView refreshStateLoading];
[UIView commitAnimations];
}
} @end

在table中处理一些事件:

为了測试加入数据后footview的位置是否会跟着变动。当点击cell的时候会加入一个数据。

为了測试载入完毕后第二次拖拽是否页面还可以完毕,当点击cell的时候foottview会停止;

下载代码:&#28;http://download.csdn.net/detail/u010123208/8036577

版权声明:本文博主原创文章。博客,未经同意不得转载。

ios-上拉电阻负载许多其他接口的更多相关文章

  1. ios 上拉载入下拉刷新Dome

    为练手写了一个小的上拉载入很多其它下拉刷新的小的Dome . 没有太多的技术含量,仅仅是作为新手的启示用.是上一篇下拉载入的扩展.先看一下那个再看这个就easy非常多. Dome下载:http://d ...

  2. iOS 上拉刷新和下拉加在更多(第三方框架EGOTableViewPullRefresh)

    #import <UIKit/UIKit.h> @interface AppDelegate : UIResponder <UIApplicationDelegate> @pr ...

  3. mui之上拉刷新和mui-content结合解决ios上拉不回弹的bug

    打电话.发短信 https://blog.csdn.net/itguangit/article/details/78210770

  4. ios系统微信浏览器、safari浏览器中h5页面上拉下滑导致悬浮层脱离窗口的解决方法

    一. 运行环境: iphone所有机型的qq浏览器,safari浏览器,微信内置浏览器(qq浏览器内核)等. 二. 异常现象: 1. 大幅度上下滑动h5页面,然后停止滑动,有时候会影响到页面滚动,如局 ...

  5. 【Android-自定义控件】SwipeRefreshDemo 下拉刷新,上拉加载

    参考:https://github.com/PingerOne/SwipeRefreshDemo 谷歌官方的SwipeRefreshLayout控件,只有下拉刷新功能. 自定义的SwipeRefres ...

  6. 微信小程序 下拉刷新 上拉加载

    1.下拉刷新  小程序页面集成了下拉功能,并提供了接口,我们只需要一些配置就可以拿到事件的回调. 1. 需要在 .json 文件中配置. 如果配置在app.json文件中,那么整个程序都可以下拉刷新. ...

  7. js 前端实现下拉刷新 上拉加载

    效果 css html,body{ height:100%; // 其他界面未设置html 无法监听scroll } /* 下拉刷新 */ .refresh-loading { transition: ...

  8. iOS开发 XML解析和下拉刷新,上拉加载更多

    iOS开发 XML解析和下拉刷新,上拉加载更多 1.XML格式 <?xml version="1.0" encoding="utf-8" ?> 表示 ...

  9. IOS tableview下拉刷新上拉加载分页

    http://code4app.com/ios/快速集成下拉上拉刷新/52326ce26803fabc46000000 刷新没用用插件,加载使用的MJ老师的插件. - (void)viewDidLoa ...

随机推荐

  1. AdaBoost中利用Haar特征进行人脸识别算法分析与总结1——Haar特征与积分图

    原地址:http://blog.csdn.net/watkinsong/article/details/7631241 目前因为做人脸识别的一个小项目,用到了AdaBoost的人脸识别算法,因为在网上 ...

  2. android画笔错位问题的解决

    下面的画画板的代码: public class MainActivity extends Activity { private ImageView iv; private Bitmap baseBit ...

  3. leetcode回文子串拆分-最小拆分次数

    转载请注明来自souldak,微博:@evagle 上一篇是要输出所有的可能拆分,这回是要输出拆分次数最少的切割次数. 如果直接按照上一篇那么做的话,就会超时,因为我们在判断s[i][j]是否是回文的 ...

  4. MySql数据库SQL语句将编码

    -- 查看所有字符编码 SHOW CHARACTER SET; -- 查看创建数据库的指令并查看数据库使用的编码 show create database dbtest; -- 查看数据库编码: sh ...

  5. TMS320F28335项目开发记录5_28335之CCS编程基础

    CCS开发环境已经为我们封装好了很多片内外设寄存器的结构体,我们仅仅须要包括对应的官方的头文件就能够使用了,那么它的内部详细是怎样实现的呢? 以下来一个典型的样例: 1.使用结构体和联合体 A.用st ...

  6. Selenium执行测试脚本稳定性的一些经验分享交流

    Selenium执行测试脚本稳定性的一些经验分享交流 公司的自动化WEB测试框架IATA已上线运行了一段时间,期间发现一些脚本稳定性的问题,与大家分享一下. CASE执行游览器:ie firefox ...

  7. FZU 1686(重复覆盖)

    题目连接:http://acm.hust.edu.cn/vjudge/problem/viewProblem.action?id=31370 题意:用尽量少r*c的小矩形覆盖大矩形n*m中的所有1,将 ...

  8. spring原拦截器配置与新命名空间mvc:interceptors配置拦截器对照与注意事项

    原先,我们是这么配置拦截器的 <bean id="openSessionInViewInterceptor"class="org.springframework.o ...

  9. linux crontab定时执行shell脚本

    linux下使用crontab命令被用来提交和管理用户的需要周期性执行的任务,示例如下:crontab -e 编辑周期任务30 21 * * * /etc/init.d/smb restart 每晚的 ...

  10. Install Linux Kernel - AT91SAM9260EK

    两.AT91SAM9260EK 2.1下载 介绍页: http://www.at91.com/linux4sam/bin/view/Linux4SAM/LegacyLinuxKernel 下载页: a ...