Seems like a pretty basic issue, but I have a tableViewController and at the top of the screen I've got a collection, beneath this I want to include a Search Bar. But for some reason it won't let me place this above the Table View Cell. It will let me add it into the collection view bizarrely but it goes behind the cells.
Is this a limitation caused by the fact I've included a Collection at the top of the screen? Is there only space for one element above a table on a tableViewController? Is there a workaround whilst still using a tableViewController?
Likely a noob question, but I'm still v noob
CodePudding user response:
Is there only space for one element above a table on a tableViewController?
Correct. You get one header view area, and one footer view area for the tableViewController as a whole. (plus extras for the sections)
If you want a quick solution for a simple table then the tableViewController saves you about 60 seconds. - but if you want to do something more complex now or later, then you may want to consider using a regular UIViewController, dropping a UITableView into it and applying constraints as needed.
You would also need to remember to set the tableView dataSource and delegate up and comply to their protocols - or you go the diffableDataSource route.
CodePudding user response:
Thanks @agentoverflow I couldn't find any documentation that explained the limitations of a tableviewController. Came up with my own solution. Put a view into the header area and put my collection view and search bar into that. Hooked the code up for both elements and both are working as expected...