Don't say much, just upload the code description
1. Put EGORefreshTableHeaderView.h and Egorefreshtableheaderview. m files pulled into the project
2.viewcontroller file Add Reference #import "EGORefreshTableHeaderView.h" and protocol <</span>egorefreshtableheaderdelegate>
3. Defining objects
Egorefreshtableheaderview *refreshview;
BOOL Reloading;
Note that reloading is a must.
4 Implementation Delegate
#pragma mark-egorefreshtableheaderdelegate Methods
// drop-down controls Refresh trigger events
-(void) Egorefreshtableheaderdidtriggerrefresh: (egorefreshtableheaderview*) view{
[ self reloadtableviewdatasource];
}
-(BOOL) egorefreshtableheaderdatasourceisloading: (egorefreshtableheaderview*) view{
return Reloading ; Should return if data source model is reloading
}
-(nsdate*) egorefreshtableheaderdatasourcelastupdated: (egorefreshtableheaderview*) view{
return [nsdate date]; Should return date data source is last changed
}
#pragma mark-uiscrollviewdelegate Methods
-(void) Scrollviewdidscroll: (uiscrollview *) scrollview{
[refreshview egorefreshscrollviewdidscroll: ScrollView];
}
-(void) scrollviewdidenddragging: (uiscrollview *) ScrollView willdecelerate: (BOOL) decelerate{
[refreshview egorefreshscrollviewdidenddragging: ScrollView];
}
Note to implement Uiscrollviewdelegate
5 functions to add load data and functions to load data
#pragma mark Data Source loading/reloading Methods
The drop-down action triggers the function called by the event. Send a data request here
-(void) reloadtableviewdatasource{
Should is calling your Tableviews data source model to reload
Put here just for demo
NSLog(@ "dragging!!!" );
Timer= [NstimerScheduledtimerwithtimeinterval:5Target: SelfSelector:@selector(Doneloadingtableviewdata)UserInfo:NilRepeats:NO];
Reloading = YES;
}
The request End Function. Here to close the dropdown view. and update the table view
-(void) doneloadingtableviewdata{
Model should call the when it is done loading
NSLog(@ "Stop loading");
Timer = nil;
reloading no
[refreshview egorefreshscrollviewdatasourcedidfinishedloading:self. TableView ];
listdata addobjectnsstring alloc " initwithformat< Span style= "Line-height:16.5px;color:rgb (0,0,0);" >: @ "%d" ,[ ]]];
[self. TableView reloaddata];
}
This article is from the "zhuoking" blog, make sure to keep this source http://9951038.blog.51cto.com/9941038/1772576
How to use IOS Egorefreshtableheaderview