IOS Add Refresh button to refresh the current page

Source: Internet
Author: User

The refresh button is added to the top right of the navigation bar, there is already a drop-down refresh function, now just don't want to go to the top of each refresh, so add a button like this.

Code:

Add Refresh button -2015.10.10

Uibarbuttonitem *refreshbtn = [[Uibarbuttonitem alloc]initwithtitle:@ " Refresh "

style:uibarbuttonitemstyleplain

target: Self

Action:@selector (Datarefresh)];

self. Navigationitem. Rightbarbuttonitem = refreshbtn;

Add complete -2015.10.10

# pragma mark event to add Refresh button-2015.10.10

-(void) datarefresh{

record The location of the current cell

float currentposition = self . TableView. Contentoffset. y;

NSLog (@ " current position y =%.f", currentposition);

Data Refresh

[Self egorefreshtableheaderdidtriggerrefresh:_refreshheaderview];

[self reloadtableviewdatasource];

[self loaddata];

the UI interface's offset does not change

[Self. tableView setcontentoffset:cgpointmake (self. TableView. Contentoffset. x, currentposition)];

animation effects

[self performselector:@selector (doneloadingtableviewdata) withobject:nil afterdelay: 1.0];

}

IOS Add Refresh button to refresh the current page

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.