最近在研究下拉刷新的一些問題,先給大家介紹下系統(tǒng)的下拉刷新。。如果問題望指點(diǎn)出來。。
1、UIRefreshControl的簡單用法
#######效果圖
1.gif
#######代碼《很簡單的額幾句話》
//添加刷新控件 UIRefreshControl繼承UIControl
UIRefreshControl *control=[[UIRefreshControl alloc]init];
//加載文字
control.attributedTitle = [[NSAttributedString alloc] initWithString:@"努力賺錢中。。。。"];
//設(shè)置菊花顏色
control.tintColor = [UIColor redColor];
//實現(xiàn)方法 《實現(xiàn)數(shù)據(jù)得請求》
[control addTarget:self action:@selector(refreshStateChange:) forControlEvents:UIControlEventValueChanged];
//加到tableView上
[self.tableView addSubview:control];
#######實現(xiàn)方法
/** 系統(tǒng)下拉刷新 */
- (void)refreshStateChange:(UIRefreshControl *)control
{
[[HttpRequestTool shareManager] requestWithUrlString:@"http://www.duitang.com/napi/topic/list/by_tags" parameters:nil successBlock:^(AFHTTPRequestOperation *operation, id responseObject) {
NSDictionary * dataDict = [responseObject objectForKey:@"data"];
NSArray * object_list = [dataDict objectForKey:@"object_list"];
for (NSDictionary * objDict in object_list) {
JiChuModel * model = [JiChuModel jiChuModelDict:objDict];
JiChuFrameModel * frameModel = [[JiChuFrameModel alloc]init];
frameModel.model = model;
[_dataArray addObject:frameModel];
}
[self.tableView reloadData];
//結(jié)束刷新
[control endRefreshing];
} failureBlock:^(AFHTTPRequestOperation *operation, NSError *error) {
//結(jié)束刷新
[control endRefreshing];
}];
}
靠山山會倒,靠水水會流,靠自己永遠(yuǎn)不倒。。。
2016年09月27日 未完待續(xù)。。