1. Create 2 TableView on storyboard and constrain it with AutoLayout.
2. Drag it in on the Viewcontroller.
@property (Weak, nonatomic) Iboutlet UITableView *lefttableview; @property (weak, nonatomic) iboutlet UITableView * Righttableview;
3. Implement the Proxy method;
Emphasis: The method of distinguishing tableview is to use the method of object comparison, pass in TableView is which tableview.
-(Nsinteger) TableView: (UITableView *) TableView numberofrowsinsection: (nsinteger) Section {if ([TableView isequal: Self.lefttableview]) {return 5;} else if ([TableView IsEqual:self.rightTableView]) {return 3;} return 0;} -(UITableViewCell *) TableView: (UITableView *) TableView Cellforrowatindexpath: (Nsindexpath *) Indexpath {if ([ TableView IsEqual:self.leftTableView]) {static NSString *identifier = @ "Leftcell"; return Letfcell;} else if ([ TableView IsEqual:self.rightTableView]) {static NSString *identifier = @ "Rightcell"; .... return Rightcell;} return nil;}
--end
Copyright NOTICE: This article is the original blogger article, reproduced please indicate the source: http://blog.csdn.net/zhangwenhai001
How to display 2 TableView on an IOS Viewcontroller