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.
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Hamidreza VakilianSenior iOS/Android 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.

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.