I have been recently asked to implement side menu with static cells using TableView* + adding some elements on the screen. My initial implementation idea was using to add TableView with other UI components in UIViewController. It turned out that using TableView (not the TableViewController) does not support static cells (the xCode complains - the project does not even compile). So the UITableViewController must be used.
Actually the solution is very simple, but you must be aware of it:
- implement your screen where the TableViewController should be - add any other UI elements to the screen. For the place where you want to have the UITableViewController search for ContainerView and add it to the screen (feel free to add any auto-layout, constraints there)
- add UITableViewController to the storyboard - next to you ViewController. Configure it as you wish
- select ContainerView, hold CTRL + click and create segue to the TableViewController. From the dropdown menu choose the embed segue. Run the app and voila - TableViewController is inside the first screen :)
- feel free to check the demo here: https://github.com/leondobnik/EmbeedTVCDemo.git
![]() |
Storyboard solution of embedding |
![]() |
The result - UITableViewController inside UIViewController |
No comments:
Post a Comment