0

Hi :) I'm having a tableView and I want to have a tableView inside my UITableViewCell, now I was thinking to create a custom tableView inside UIView class and then present it inside the UITableViewCell using UIView, I'm wondering is it possible or I'm approaching the problem wrong :)

Here's a picture of what I would like to achieve: Link

2 Answers 2

1

Although you CAN add a UITableView to any UIView, that means also to a UITableViewCell, what you are trying to achieve looks like a UITableView with UITableView.Style.insetGrouped.

This new style for table views is available at iOS13.

Just initialize your table view with this style, e.g.:

let tableView = UITableView(frame: .zero, style: .insetGrouped)

You can see the documentation here: (https://developer.apple.com/documentation/uikit/uitableview/style/insetgrouped)

In this thread, there is the screenshot of this UITableView.Style:

TableView with inset grouped style: Have rounded corners even with hidden cells

Sign up to request clarification or add additional context in comments.

5 Comments

@Iaka Oh I see, well the problem is my app only works for users with iOS 10 and above :\
Okay I found out I can do it like : let tableView = UITableViewController(style: .grouped) the thing is, is that possible to do a uitableviewcontroller inside UIView?
You can add a UITableView (not a UITableViewController) to a UIView.
However, I think you should be able to subclass UITableView and modify its appearance to be similar to .insetGrouped instead of adding a UITableView to a UIView.
well i added a tableView inside. a UIView, the thing is I can't use .insetGrouped due to the fact that is only for iOS13+ and the app got users for iOS10+ lol but thanks for the help I solved it :)
0

You can achieve that kind of look by using inset grouped style on UITableView and by adding sections to UITableView

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.