I have a view controller (derived from UIViewController not UITableViewController) containing a table view. The controller and view are both within the same xib.
I want to add a segmented control to appear at the bottom of the screen, with the table view taking up the rest of the space above it.
However in IB it will not let me place the segmented control as a direct child of the view controller, it will only let me place it as a child of the table view i.e. the hierarchy looks like this:
Navigation Controller
Navigation Bar
Main View Controller – Item
Table View
Segmented Control – First, Second
Navigation Item – Item
Bar Button Item – Style
If I run it like this then the segmented control floats up and down depending upon how many items there are in the table view.
What can I do to get it to be locked to the bottom of the screen?
UPDATE:
I got nearer – I added a view as a child of the main view controller and made the table view and segment control children of that, but now only the top half of the control appears when I run the simulator but everything looks fine in IB, why is there a discrepency?
Side question – as a starting point I’m using one of Apple’s sample project, why was there no main view? When should you and when should you not have a main view?
Thanks
Just open your xib and expand your view and drag Tableview control under View and also drag segmented control under view not in tablview this will work.
you need to set frame of both in you viewDidLoad