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