-1

I want to customize my tableview. I want to add another tableview in cell. Can we add tableview in cell of another tableview?

Please give me some ideas.

Eric Aya
  • 69,473
  • 35
  • 181
  • 253
ChhengRavy
  • 53
  • 8
  • Of course you can. What is your problem ? Share your code. – Pipiks Nov 22 '17 at 07:54
  • @Pipiks I don't know to how to add tableview in cell. I try to find with other tutorials but don't have any solution. If you know so tutorial link, can you share me? I just know how to add collection view in cell of tableview – ChhengRavy Nov 22 '17 at 07:57

2 Answers2

1

You can embed a UITableView into another UITableView's cell, but due to potential issues with the embedded UIScrollViews it is not recommended.

If you feel like you need a table in a table, first consider if it is not possible to achieve the desired behavior by using sections and cells in the sections (a section in a table might represent the top tableView's cell, and cells in the given section would represent the embedded tableView's cells).

Milan Nosáľ
  • 19,169
  • 4
  • 55
  • 90
  • Here is my design for my app. Please spend about 1 minute to look on it. Can you give me what view that I can use? https://drive.google.com/open?id=1Y9Xgzuw5XV9aUnJDHv5TGn6uUlKPSFMh – ChhengRavy Nov 22 '17 at 08:59
  • I would start with `UITableView`, for topmost items I would probably use horizontal `UICollectionView`.. for the rest of the design, I would try to use section (and section headers) to create sections (Sport, Toys, etc.) and simple cells (unless those should be horizontally scrollable - then again, `UICollectionView`) – Milan Nosáľ Nov 22 '17 at 09:38
  • Nosal, Thank you. I will try – ChhengRavy Nov 23 '17 at 01:20
1

There is no problem with adding a UITableView into a a UITableViewCell, since both of them are UIViews its simply would be translated to adding a subview to a view...

However, keep in mind to consider the following issues:

1- From a user experience perspective, that would be a vertical scroll view inside another vertical scroll view (are you ok with that?).

2- For each cell -in the main container table view-, you would need to handle the table view delegates/datasources. For understanding the logic of how this could be done, you might want to check:

Ahmad F
  • 30,560
  • 17
  • 97
  • 143
  • Here is my design for my app. Please spend about 1 minute to look on it. Can you give me what view that I can use? https://drive.google.com/open?id=1Y9Xgzuw5XV9aUnJDHv5TGn6uUlKPSFMh – ChhengRavy Nov 22 '17 at 09:01
  • @ChhengRavy for me, you should add a `UITableView`, inside their cells add a `UICollectionView` (As I mentioned, check "Putting a UICollectionView in a UITableViewCell in Swift"). – Ahmad F Nov 22 '17 at 09:05
  • Thank you sir. I will try to follow your advice – ChhengRavy Nov 23 '17 at 01:18