IOS comes with refresh feature

Source: Internet
Author: User

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);}


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.