Because the table app has two UI design patterns: Paging mode, pull-down refresh mode.
Where drop-down refreshes are widely used (Sina Weibo, QQ)
Here spit trough a QQ ink, in fact, the application of PC desktop is OK, the flat of the time. But iOS is such a big market, but now it's all IOS8, why are you still using IOS6 's dropdown to refresh the "gum Candy" ui style.
IOS6 later adds a Uirefreshcontrol drop-down refresh class that can only be applied to the table view interface at this time.
In Xcode6, there is no more drag-and-drop, like a label, in the story version. So the layout is not too much to consider.
The Code section is reusable and is now used as a library.
H file:
#import <UIKit/UIKit.h> @interface Tableviewcontroller:uitableviewcontroller@property (nonatomic, Strong) Nsmutablearray * LOGS; @end
M File:
#import "ViewController.h" @interface Tableviewcontroller () @end @implementation tableviewcontroller-(void) viewdidload {[Super viewdidload]; Initializes the variable and time self. Logs = [[Nsmutablearray alloc] init]; NSDate *date = [[NSDate alloc] init]; [Self. Logs Addobject:date]; Initialize Uirefreshcontrol//RC as a pointer to the control, can only be used in the Table view interface//About layout problems can not be considered, about Uitableviewcontroller will be automatically placed in the table view Uirefresh Control *RC = [[Uirefreshcontrol alloc] init]; Rc.attributedtitle = [[nsattributedstring alloc]initwithstring:@ "dropdown refresh"]; Be sure to note the spelling check inside the selector [RC addtarget:self action: @selector (Refreshtableview) forControlEvents: Uicontroleventvaluechanged]; Self.refreshcontrol = RC;} -(void) didreceivememorywarning {[Super didreceivememorywarning]; Dispose of any resources the can be recreated.} -(void) refreshtableview{if (self.refreshControl.refreshing) {//Determines whether it is in a refreshed state self.refreshControl.attributedTitl e = [[Nsattributedstring alloc] initwithstring: @ "Loading ..."]; Add a new emulator nsdate *date = [[NSDate alloc] init]; After the impersonation request is completed, the callback method Callbackmethod [self performselector: @selector (callbackmethod:) withobject:date Afterdelay:3]; }}-(void) Callbackmethod: (ID) obj{[self.refreshcontrol endrefreshing]; Stop the drop-down refresh control, back to the initial state self.refreshControl.attributedTitle =[[nsattributedstring alloc]initwithstring:@ "drop-down refresh"]; The text changes back [self. Logs AddObject: (nsdate *) obj]; [Self.tableview Reloaddata];} #pragma mark---uitableviewdatasource code-(Nsinteger) Numberofsectionsintableview: (UITableView *) tableview{return 1;} -(Nsinteger) TableView: (UITableView *) TableView numberofrowsinsection: (nsinteger) section{return [self. Logs count];} -(UITableViewCell *) TableView: (UITableView *) TableView Cellforrowatindexpath: (Nsindexpath *) indexpath{// This can be said to be the most important code segment of the cell section//define the cell, and then determine whether cellidentifier reuse static nsstring *cellidentifier = @ "Cell"; UITableViewCell *cell = [TableView Dequeuereusablecellwithidentifier:cellIdentifier]; if (cell = = nil) {cell = [[UITableViewCell alloc] initwithstyle:uitableviewcellstylevalue1 reuseidentifier:cellid Entifier]; }//Then get time nsdateformatter *dateformat = [[NSDateFormatter alloc]init]; [DateFormat setdateformat:@ "Yyyy-mm-dd HH:mm:ss"]; Then update cell cell.textLabel.text = [DateFormat stringfromdate:[self. Logs Objectatindex:[indexpath Row]]; Cell.accessorytype = Uitableviewcellaccessorydisclosureindicator; return cell;} @end
Note that there is no spelling check in @selector (), so make sure you spell it correctly!
UI drop-down Refresh (iOS development)