This is the only way to introduce the use of Uirefreshcontrol, although ego has been used quite comfortable, but the official gave. It's pretty simple after all.
============================================= =====
The Uirefreshcontrol has a default height and width
Once created, it is automatically managed. Only when the user is forced to refresh to refresh, especially ... That chrysanthemum, the greater the force, the faster the speed, the feeling is good oh. (Instant ... Evil)
Here's how to use:
self.refreshcontrol = [[uirefreshcontrol alloc] init]; self.refreshcontrol.attributedtitle = [[nsattributedstring alloc] initwithstring:@ "in Refresh"]; [ Self.refreshcontrol addtarget:self action: @selector (insertnewobject:) forcontrolevents: Uicontroleventvaluechanged]; [self.tableview addsubview:self.refreshcontrol];
-(void) Insertnewobject: (id) sender{self.numberofnewposts = [self getrandomnumberbetween:0 to:4]; NSLog (@ "%d new fetched objects", self.numberofnewposts); for (int i = 0; i < self.numberofnewposts, i++) {int addpost = [self getrandomnumberbetween:0 to: (int) ([Self.poss Ibletabledata count]-1)]; [Self.objects Addobject:[self.possibletabledata Objectatindex:addpost]; } [Self.refreshcontrol endrefreshing]; [Self.tableview Reloaddata];} -(int) Getrandomnumberbetween: (int) from to: (int) to {return (int.) from + arc4random ()% (to-from+1);}