Search code examples
watchkitwatchos-2wkinterfacetable

How to create a Static Table in WatchKit


I am creating a table in my WatchKit app but I want it to be a static table.

How do I configure the table so it's static? I looked in the attributes inspector but there is no setting to change a dynamic table to a static table.


Solution

  • You can't, at present, since watchOS WKInterface tables are dynamic: they require you to programmatically configure both the number of rows and the row controllers.

    You could file a feature request with Apple. In the meantime, you could either

    • configure your table programmatically (which would involve setting up a custom row for each different type of static row), or
    • just drag groups and their controls to the storyboard, to represent each static row. Depending on the controls, you may have to tweak the group height and background color to make the groups consistently look like an WKInterfaceTable.

    The first option would require more code and classes. The second, while much simpler, is more fragile, as it would rely on Apple not changing the appearance for their table row.

    Alternatively, you could wait for the new watch OS to be presented at WWDC in a few weeks before making any decision.