How to use IOS Egorefreshtableheaderview

Source: Internet
Author: User

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.