Some time ago the company in the development of a project, while now have time to put the knowledge point of the collation.
Item Product Details page at that time is imitation Taobao, the use of Third-party Library is Mjrefresh, pull operation and drop-down operation of the refresh effect is the Mjrefresh refresh effect from a new classification package, thank Gego!!!
Basic ideas:
1, set a uiscrollview as the bottom of the view, and set pagination to two pages
2, and then add a uitableview on the first page and set up the table can be loaded (pull operation is to let the view scroll to the next page)
3, add a Uiscrollview on the second page and set to have a Drop-down refresh operation (the Drop-down operation is to let the view scroll to the previous page)
4, the second page Uiscrollview add sub-UIView, general merchandise graphics and text details, product parameters, shops and so on
5, demo only provide a simple idea, the implementation of the project is basically the same
/** Package Refresh Mjrefresh * * *
#import "qrg_mjrefreshautofooter.h"
#import "Qrg_mjrefreshnormalheader.h"
#import "CollectionViewCell.h"
#define WIDTH [uiscreen mainscreen].bounds.size.width
#define HEIGHT [UIScreen Mainscreen].bounds.size.height
#define Arccolor (arc4random ()% 255/256.0)
#import "ViewController.h"
Main code
-(void) viewdidload {[Super viewdidload];
/** bottom view*/Uiscrollview *mainscrollview = [[Uiscrollview alloc] init];
mainscrollview.scrollenabled = NO;
Mainscrollview.frame = CGRectMake (0, 0, WIDTH, HEIGHT);
Mainscrollview.contentsize = Cgsizemake (WIDTH, HEIGHT * 2);
Mainscrollview.backgroundcolor = [Uicolor Greencolor];
mainscrollview.pagingenabled = YES;
Mainscrollview.bounces = YES;
[Self.view Addsubview:mainscrollview];
/** first page table*/onetable = [[UITableView alloc] init];
Onetable.frame = CGRectMake (0,0, WIDTH, HEIGHT-64);
Onetable.separatorcolor = [Uicolor Greencolor];
Onetable.delegate = self;
Onetable.datasource = self;
Onetable.rowheight = 80;
[Mainscrollview addsubview:onetable];
/** the second page scrollview*/uiscrollview *twoscrollview = [[Uiscrollview alloc] init];
Twoscrollview.frame = CGRectMake (0, HEIGHT +, WIDTH, HEIGHT-64);
Twoscrollview.contentsize = Cgsizemake (WIDTH * 3, HEIGHT-64);
Twoscrollview.backgroundcolor = [Uicolor Cyancolor]; Twoscrollview.pagingenabled = YES;
Twoscrollview.bounces = NO;
[Mainscrollview Addsubview:twoscrollview];
/** second page table*/twotable = [[UITableView alloc] init];
Twotable.frame = CGRectMake (width, 0, width, HEIGHT-64);
Twotable.separatorcolor = [Uicolor Redcolor];
Twotable.delegate = self;
Twotable.datasource = self;
[Twoscrollview addsubview:twotable];
/** the second page uicollectionview*/uicollectionviewflowlayout *flow = [[Uicollectionviewflowlayout alloc] init];
[Flow setscrolldirection:uicollectionviewscrolldirectionvertical]; Uicollectionview *twocollectionview = [[Uicollectionview alloc] Initwithframe:cgrectmake (0, 0, WIDTH, HEIGHT-64) Collec
Tionviewlayout:flow];
Twocollectionview.backgroundcolor = [Uicolor Lighttextcolor];
Twocollectionview.delegate = self;
Twocollectionview.datasource = self;
[Twoscrollview Addsubview:twocollectionview];
[Twocollectionview Registerclass:[uicollectionviewcell class] forcellwithreuseidentifier:@ "Coll"]; [Twocollectionview registernib:[uinib nibwithnibname:@ "Collectionviewcell" Bundle:nil] forcellwithreuseidentifier:@ "Coll"]; Set UITableView pull Load Onetable.mj_footer = [Qrg_mjrefreshautofooter footerwithrefreshingblock:^{//上拉, Perform the corresponding operation---change the scrolling of the underlying scrolling view to the corresponding position//set the animation effect [UIView animatewithduration:0.5 delay:0.0 options:
Uiviewanimationoptionlayoutsubviews animations:^{//self.scrollV.contentOffset = Cgpointmake (0, Iphone_h);
[Mainscrollview setcontentoffset:cgpointmake (0, HEIGHT)];
} completion:^ (BOOL finished) {//end loading [Onetable.mj_footer endrefreshing];
}];
}]; Set Twocollectionview has drop-down operation twocollectionview.mj_header = [Qrg_mjrefreshnormalheader headerwithrefreshingblock:^{//
The dropdown performs the corresponding operation//Self.scrollV.contentOffset = Cgpointmake (0,0);
[UIView animatewithduration:1 animations:^{[Mainscrollview setcontentoffset:cgpointmake (0,-64)];
}];
End loading [Twocollectionview.mj_header endrefreshing];
}]; Set twotable has drop-down operation twotable.mj_header = [Qrg_mjrefreshnormalheadeR headerwithrefreshingblock:^{//dropdown performs the corresponding operation//Self.scrollV.contentOffset = Cgpointmake (0,0);
[UIView animatewithduration:1 animations:^{[Mainscrollview setcontentoffset:cgpointmake (0,-64)];
}];
End loading [Twotable.mj_header endrefreshing];
}];
}
Pragma mark---------Delegate
#pragma mark---------tabledelegate-(CGFloat) TableView: (UITableView *) TableView Heightforrowatindexpath: (
Nsindexpath *) Indexpath {cgfloat height;
if ([TableView isequal:onetable]) {height = 80;
}else {return 120;
return height;
}-(Nsinteger) TableView: (UITableView *) TableView numberofrowsinsection: (nsinteger) section {return 10;} -(UITableViewCell *) TableView: (UITableView *) TableView Cellforrowatindexpath: (Nsindexpath *) IndexPath {static
NSString *cell = @ "Cell";
UITableViewCell *cell = [TableView Dequeuereusablecellwithidentifier:cell];
if (!cell) {cell = [[UITableViewCell alloc]initwithstyle:uitableviewcellstyledefault Reuseidentifier:cell];
} cell.textLabel.text = [NSString stringwithformat:@ "%LD--ASKL", Indexpath.row];
Cell.imageView.image = [UIImage imagenamed:@ "6"];
return cell; #pragma mark---------collectionviewdelegate-(Nsinteger) CollectionView: (Uicollectionview *) CollectionView Numberofitemsinsection: (Nsinteger) Section {return 20; }-(Cgsize) CollectionView: (Uicollectionview *) CollectionView layout: (uicollectionviewlayout *) collectionviewlayout
Sizeforitematindexpath: (Nsindexpath *) Indexpath {return Cgsizemake (150, 100);} -(Uicollectionviewcell *) CollectionView: (Uicollectionview *) CollectionView Cellforitematindexpath: (NSIndexPath *)
Indexpath {static NSString *coll = @ "Coll";
Collectionviewcell *cell = [CollectionView dequeuereusablecellwithreuseidentifier:coll ForIndexPath:indexPath];
Cell.backgroundcolor =[uicolor Greencolor];
return cell;
}
The above is the entire content of this article, I hope to help you learn, but also hope that we support the cloud habitat community.