IOS Mjrefresh Pull-up reload (can add GIF chart) summary

Source: Internet
Author: User

1. First go to GitHub to download the latest version of MJ Refresh Library downloads MJ Link



Add related code in 2.tableVIew

     _tableview  = [[ uitableview &NBSP; alloc< Span style= "Color:rgb (0,0,0)" >]&NBSP; initwithframe: Cgrectmake ( 0   0 ,&NBSP; mcappwidth ,&NBSP; mcappheight &NBSP;-&NBSP; 64

_tableview. BackgroundColor = myclearcolor;

_tableview. Separatorstyle  =  Uitableviewcellseparatorstylenone;

_tableview. Delegate  =  Self ;

_tableview. DataSource  =  Self ;

_tableview. Showsverticalscrollindicator = NO;

_tableview. Scrollstotop = YES;

[Self. View addsubview:_tableview];

[_tableview addgifheaderwithrefreshingtarget: self Refreshingaction:@selector(loaddata)];

[_tableview addgiffooterwithrefreshingtarget: self Refreshingaction:@selector(loadmoredata)];

[ self gif];


LoadData for you the method of requesting network data when the pull-down is refreshed Loadmoredata the method of requesting network data when you pull up the load



3. [Self GIF]

-(void) gif

{

nsmutablearray *idleimages = [nsmutablearray array];

The GIF graph that appears when you refresh it needs to be added to the array in a loop

for (nsuinteger i = 1; I <= 5; i++) {

UIImage *image = [UIImage imagenamed: [nsstring stringwithformat:@ " Img_loading-%lu.png ", (unsigned long) i]];

[Idleimages AddObject: image];

}

[_tableview. Gifheader setimages: idleimages forstate:mjrefreshheaderstateidle];

_tableview. Giffooter. Refreshingimages = idleimages;

_tableview. Gifheader. Updatedtimehidden = YES;

// set an animated picture of the state to be refreshed (a state that will refresh as soon as it is released)

nsmutablearray *refreshingimages = [nsmutablearray array];

for (nsuinteger i = 1; I <= 5; i++) {

UIImage *image = [UIImage imagenamed: [nsstring stringwithformat:@ " Img_loading-%lu.png ", (unsigned long) i]];

[Refreshingimages AddObject: image];

}

[_tableview. Gifheader setimages: refreshingimages forstate:mjrefreshheaderstatepulling];

}



4. Custom refresh when the top appears at the bottom of the label and GIF diagram of the frame here to cite footer example

Mjrefreshgiffooter.m

-(void) layoutsubviews

{

[super layoutsubviews];

//  indicator frame of a GIF chart

Self.Gifview.Frame=CGRectMake( Self.bounds.Origin.x+ -, Self.bounds.Origin.y+ the, Self.bounds.size.width/2, Self.bounds.size.Height/2);

if (self. Statehidden) {

self. Gifview . Contentmode  =  Uiviewcontentmodecenter;

} Else {

self. Gifview . Contentmode  =  Uiviewcontentmodescaleaspectfit;

Self. Gifview. mj_w = self. mj_w * 0.5 - N;

}

}

Mjrefreshfooter.m

-(void) layoutsubviews

{

[super layoutsubviews];

Self. Loadmorebutton. frame = self. bounds;

self. Loadmorebutton. Hidden  =  YES ;

The frame of the label

     Self.Statelabel.Frame = CGRectMake( Self.Bounds.Origin.X,  Self.Bounds.Origin.Y +  the,  Self.Bounds.Size.Width,  Self.Bounds.Size.Height / 2);

Self. Nomorelabel. frame = self. bounds;

}


The GIF frame and labelframe of the same header can be modified according to the requirements in the corresponding class.


More settings can be seen on MJ's related documents on GitHub.




Copyright NOTICE: This article for Bo Master original article, without Bo Master permission not reproduced.

IOS Mjrefresh Pull-up reload (can add GIF plates) Summary

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.