Reputation: 428
Any one please tell me how to add two tables in uiview controller?
I created a class object in rootviewController
as
mainDataViewController=[[MainDataViewController alloc]initWithStyle:UITableViewStylePlain];
And in mainDataviewController
taken as UITableviewController
@interface MainDataViewController : UITableViewController<UITableViewDataSource,UITableViewDelegate>
Now, I Want to add three tables in mainDataViewController
.
Please give me some idea for solving this.
Upvotes: 1
Views: 884
Reputation: 12641
follow these steps.
1)Create a tableViewController with xib. 2)Create only two other xib's as given screenshots below:--
3)Drag uitableView from object window.
4)Change its class to TableViewController's class you have firstly created.
5)Connect file owner's view delegate to tableView.
6) And use code as ------
- (void)viewDidLoad
{
MYViewController *FirstTableController=[[MYViewController alloc] initWithNibName:@"MYViewController" bundle:nil];
MYViewController *secondTableController=[[MYViewController alloc] initWithNibName:@"MYSecondController" bundle:nil];
MYViewController *thirdTableController=[[MYViewController alloc] initWithNibName:@"MYThird" bundle:nil];
[super viewDidLoad];
// Do any additional setup after loading the view, typically from a nib.
}
Or
#import <UIKit/UIKit.h>
@interface MYViewController : UITableViewController
{
IBOutlet UITableView *f_table,*s_table,*t_table; //outlets for different tableViews in xib.
}
@end
- (void)viewDidLoad
{
[super viewDidLoad];
self.view=f_table; // when working with first table.
self.view=s_table; //working with second table.
self.view=t_table; //working with third table.
}
Upvotes: 2
Reputation: 1703
1) First add tableview on your viewController xib file
2) declare variables for your tableviews
3) synthesize properthies
4) add outlets to your propethies
Now you can use them...
Upvotes: 0
Reputation: 2414
I think you have not searched well.
Please have a look at this.
How to use 2 UITableView in a UIViewController?
Upvotes: 0