Search code examples
swiftapple-watchwatchos-2

Can I programmatically create WKInterfaceButton?


just a quick question if this is possible at all: can I create WKInterfaceButton elements for the AppleWatch programmatically? Or do I have to layout everything in InterfaceBuilder and cannot dynamically add UI elements on the watch?

So far I haven't found anything like this for the AppleWatch with watchOS 2 and I am unclear about the documentation.

Thanks for any insights.


Solution

  • You cannot create WKInterfaceObjects programmatically and add them to the view hierarchy. The only exception being WKInterfaceControllers that you can push / present programmatically (although you still have to add them to the storyboard first)