In a single UiView controller class i’ve added 3 UITableView.
UITableView *ChaptersTableView;
UITableView *SubChaptersTableView;
UITableView *SubTopics1TableView;
Now in ViewDidLoad of class i’ve initialized these TableView’s & calling the Delegate & Datasource methods on these Table View’s.
ChaptersTableView = [[UITableView alloc]initWithFrame:CGRectMake(0, 0, 300, 300)];
ChaptersTableView.delegate=self;
ChaptersTableView.dataSource=self;
SubChaptersTableView = [[UITableView alloc]initWithFrame:CGRectMake(0, 0, 300, 300)];
SubChaptersTableView.delegate=self;
SubChaptersTableView.dataSource=self;
SubTopics1TableView = [[UITableView alloc]initWithFrame:CGRectMake(0, 0, 300, 300)];
SubTopics1TableView.delegate=self;
SubTopics1TableView.dataSource=self;
I wish to have different content & height for rows of different Table views. For eg. TableView1 will have cell height of 20, TableView2 will have cell height of 40 & TableView3 will have cell height of 60.
So how do i go about customizing these delegate & datasource methods depending on the tableView they are called for?
Thanks.
The delegate methods return the tableview object. Hence while creating you can tag the tableviews like this.
SubTopics1TableView.tag = 0, SubChaptersTableView.tag = 1etc.In your delegate methods check the tag and configure the tableviews.
For eg
To change how the cell will look you can use the delegate method:
To change the height of the row you can use: