Uitableviewcontroller Refresh Controls in iOS

Source: Internet
Author: User

Uitableviewcontroller Refresh Controls in iOSFirst, Introduction

In iOS development, using TableView interface, most will use a drop-down refresh of the control, third-party library, we generally choose the more useful mjrefresh, in fact, after iOS6, the system provides us with a native refresh control, it is very convenient to use. Just the formulation of sex is not strong, if we do not have complex needs, the use of Uirefreshcontrol is also a good choice.

Second, Uitableviewcontroller

We only need to implement the method in this way, as opposed to uiviewcontroller,uitableviewcontroller just encapsulating a uitableview internally for us and complying with the relevant protocols. Uitableviewcontroller more aspects of this is the following attribute:

@property (nonatomic) BOOL clearsselectiononviewwillappear;

This is a bool value, set to Yes, whenever the current controller calls Viewwillappare, will be the cell's selected state is canceled, which is very useful, we after clicking the cell jump interface, Pop back does not need to manually modify the cell's selected state.

In addition to this, a property is encapsulated in the Tableviewcontroller:

@property (Nonatomic, Strong, nullable) Uirefreshcontrol *refreshcontrol;

This Uirefreshcontrol class is a simple refresh control introduced after iOS6, and if we set it up, the system will give us a pull-down refresh effect when the TableView is pulled down.

Third, Uirefreshcontrol

This class is also very simple, with simple settings can show a small refresh effect, but the formulation is not strong, the main properties are as follows:

Get Refresh Status @property (Nonatomic, ReadOnly, getter=isrefreshing) BOOL refreshing;//Set Control color @property (null_resettable, Nonatomic, Strong) Uicolor *tintcolor;//set Control text @property (nullable, nonatomic, strong) nsattributedstring * Attributedtitle ui_appearance_selector;//Manual Start Refresh-(void) beginrefreshing Ns_available_ios (6_0);//End flush-(void) Endrefreshing Ns_available_ios (6_0);

It is important to note that Uirefreshcontrol is a data logical operation that inherits from Uicontrol, which triggers the Uicontroleeventvaluechange event, which we can refresh in the wake-up refresh state.

For example:

-(void) viewdidload {[Super viewdidload];    Self.refreshcontrol = [[Uirefreshcontrol alloc]init];    Self.refreshControl.tintColor = [Uicolor Greencolor];    Self.refreshControl.attributedTitle = [[nsattributedstring alloc]initwithstring:@ "]    Self.clearsselectiononviewwillappear = YES;    Self.navigationItem.rightBarButtonItem = Self.editbuttonitem; [Self.refreshcontrol addtarget:self Action: @selector (change:) forcontrolevents:uicontroleventvaluechanged];} -(void) Change: (uirefreshcontrol*) con{self.refreshControl.attributedTitle = [[Nsattributedstring alloc] initwithstring:@ "began to refresh ~ ~"];}

The effect is as follows:

Uitableviewcontroller Refresh Controls in iOS

Related Article

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.