Nested UITableView articles in Uiscrollview many, but the project needs, need to nest Uicollectionview, and Uicollectionview and UITableView have a lot of different, some knowledge to now do not understand, Over and over again, the attempt was finally made. The following are implemented:
Because I just touch iOS development, a lot of principles are still unclear, so the following steps to picture-based, the end of the article will be accompanied by the source address, can download their own research!
1. New Project
2, modify the storyboard, because to use the navigation bar, so delete the original view, from the Toolbox to drag into the Navigationcontroller, and point the entrance (cutting head) to the view; Delete the Tableviewcontroller that comes with it and drag it into the view controller, such as
3, new Tableviewcontroller,tableviewcontroller default with TableView view, so no need to tick" also create Xib file "; But collection Viewcontroller not, this is more depressed!
4, Uicollectionviewcontroller can not be used directly, testing for a long time, is not nested in ScrollView, so you can only create a view Controller, and then include collection view, need to create Xib file, open xib file to drag into collection view, and associate this view to
@property (Weak, nonatomic) IboutletUicollectionview*collection;
5, Collectionviewcontroller is more troublesome, first create the cell used by CollectionView Collectionviewcell ; and create a new empty xib;
6. Open the Collectioncell.xib, drag the collection cell from the toolbox, set the background color to yellow, and drag into a Label control; notice that the collection cell's class is just created Collectioncell "Class (not files Owner);
IboutletUILabel *label
; as shown
At this point, all the pages and the front desk have been set up
8, first fix Tableviewcontroller, the following code
tmjtableviewcontroller.m//pagetest////Created by Ejiang on 14-6-30.//Copyright (c) 2014 daijier. All rights reserved.//#import "TMJTableViewController.h" @interfaceTMJTableViewController () @end @implementation Tmjtableviewcontroller-(ID) Initwithstyle: (uitableviewstyle) style{self = [Super Initwithstyle:style];if (self) {/ /Custom initialization} returnself;} -(void) viewdidload{[superviewdidload];}-(void) didreceivememorywarning{[superdidreceivememorywarning];} #pragma Mark-table View Data Source-(Nsinteger) Numberofsectionsintableview: (UITableView *) Tableview{return 1;}-(Nsinteger) t Ableview: (UITableView *) TableView numberofrowsinsection: (nsinteger) Section{return 10;} -(UITableViewCell *) TableView: (UITableView *) TableView Cellforrowatindexpath: (Nsindexpath *) indexpath{static NSString *[email protected] "cell"; UITableViewCell *cell = [TableView dequeuereusablecellwithidentifier:cellidentifier]; if (cell==nil) {CELL=[[UITABLEviewcellalloc] InitWithStyle:UITableViewCellStyleDefaultreuseIdentifier:cellIdentifier]; } [email protected] "haha"; return cell;} @end
9, or to see the source bar, paste code is not interesting, the main steps on the above several
Source: http://download.csdn.net/detail/wuwo333/8098431
iOS uses Uiscrollview to slide UITableView and Uicollectionview left and right