iOS presentation graph drop-down refresh control

Source: Internet
Author: User

Uirefreshcontrol is using this control. This property is Refreshcontrol in Uitableviewcontroller.


The initialization of the table and the data settings are consistent with the general.



1: Initialize the Uirefreshcontrol control and bind the Pull event

// Add drop-down refresh control

*rc=[[ uirefreshcontrol ]  ];

    RC. Attributedtitle alloc  initwithstring : @ " dropdown refresh " ";

bind drop Event

[RC addTarget: self action:@selector(refreshtableview) forControlEvents:uicontroleventvaluechanged];

self. Refreshcontrol = RC;



2: Add a drop-down event function, request data in the drop-down event and modify the control state, bind the callback function

// pull-down action response function.

-(void) Refreshtableview

{

if(self. Refreshcontrol. Refreshing) {

        Self.Refreshcontrol.Attributedtitle= [[NsattributedstringAlloc]initwithstring:@"Loading in ... "];

// Add Simulation Data

nsdate *now = [[nsdate alloc] init];

          // adds a callback function that simulates the request. You need to close the load state after the request has ended.

[ self performselector:@selector(callbackmethod:) withobject: Now afterdelay:3];

}

}


3: Modify the control state in the callback function and update the data and table views.


-(void) Callbackmethod: (ID) obj

{

// End Load Status

[self. Refreshcontrol endrefreshing];

    Self.Refreshcontrol.Attributedtitle= [[NsattributedstringAlloc]initwithstring:@"Drop-down refresh"];

// add data, Refresh table

[Self. ListData addobject:(nsdate *) obj];

[self. TableView reloaddata];

}


This article is from the "zhuoking" blog, make sure to keep this source http://9951038.blog.51cto.com/9941038/1772577

iOS presentation graph drop-down refresh control

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.