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