Reputation: 177
I was tinkering with the WKInterface
and Apple Watch apps and was just wondering how to add a subview like a UIButton
or UILabel
.
It seems that
UIButton *whatever = [[UIButton alloc]init];
[self.view addsubview:whatever];
does not work for the iWatch extension. Mainly the [self.view addsubview: ]
part doesnt seem to work.
Does anyone know how to add a view programatically for apple watch or do I have to use the interface builder and drag and drop these objects.
Upvotes: 0
Views: 985
Reputation: 10961
You have to use interface builder. You cannot allocate any UI objects by yourself.
You create interface objects indirectly by adding the object to your storyboard scene and referring to it from your interface controller. After adding an element to your storyboard, create an outlet for it in your interface controller. During the initialization of your interface controller, watchOS creates the interface objects for all of your connected outlets automatically. You never create the interface objects yourself.
Upvotes: 3