[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 2859
  • Last Modified:

UITableView inside UITableViewCell in iOS

I want to create an layout in that i want to put UITableView(SubTableView) inside UITableViewCell of the first UITableView(MainTableView). The problem which I am facing is that when I call the Data Source method of MainTableView, then all the DataSource Method are initialised but when cellForRowAtIndexPath method is executed then my SubTableView in not calling it's DataSource Method for particular row of the MainTableView. Instead what it dose is that it calls the DataSource Method of MainTableView and then it calls the DataSource Method for the SubTableView. My concern is that I want to call DataSource Method for SubTableView when cellForRowAtIndexPath method is executed for the MainTableView for particular row.This is the Layout which I need to create in that there is MainTableView having two views inside one row and in first view it has SubTableView.
1 Solution
Hamidreza VakilianSenior iOS DeveloperCommented:
In this method:
-(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
if (tableView == MainTableView)
<Prepare cells for the main table>
Prepare cells for your subtables.

Generally speaking, I think you are not taking the right approach. Usually, loading a tableView inside a tableviewcell is not the best way to go with. Instead I suggest you to use UIScrollView inside each tableviewcell, especially if you want to load a limited number of views inside each cell.

Featured Post

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now