Search code examples
iosiphoneobjective-cios5

iOS static table in a view?


Sorry if this is a really silly question but I'm new to iOS. I'm trying to do this:

enter image description here

The table cells are static as the content shouldn't change (the options are the same all the time). I also need to place the submit and cancel buttons below and replace the red background with an image.

My problem is, I get the error saying:

static table views are only valid when embedded in uitableviewcontroller

So my question is, how would I embed a table inside my view, like any other element?

Thanks in advance for any help :)


Solution

  • There are two relatively simple options to build a screen like that:

    1. Make your controller a `UITableViewController, add two sections to the bottom of your static part, and put custom cells with buttons into these two sections, or
    2. Define the static content of your table in code.

    The look of your screen will change slightly for option 1, but it is important only when you have many cells, forcing the sections with buttons off the screen until the user scrolls.

    The second option requires writing some code, but not too much to cause you too much inconvenience.