I would like to create a for loop for adding labels with separators programatically. How can I do this?
Asked
Active
Viewed 658 times
0
-
1Can you please share what you have tried. We are not here to do your homework. – Mika May 25 '15 at 09:41
-
I have tried using WKInterfaceLabel to code it out, I couldn't find a way to add it into the interface. In iOS, it is addsubview, how can I do this in WatchKit? – Ngo Yen Sern May 25 '15 at 09:45
1 Answers
3
You can't programmatically create a view in WatchKit you must scope it out entirely in storyboard.
EDIT:
The way this works is that views are preloaded on the watch at the time the app is installed. The data if then gathered by an extension that is running on your phone. Once the phone has the relevant data it assignes the data to the view that is already on the watch. There is no mechanism to transfer UI components from the extension to the watch.
Thanks @NgoYenSern for the comments.

Mika
- 5,807
- 6
- 38
- 83
-
because my code contains of Web API GET method and I wanted to loop all the information out, any other ways that you would recommend to solve this ? – Ngo Yen Sern May 25 '15 at 09:55
-
1
-
-
Yes :) @Mikael, It's not batter that we are adding subviews like lable to show as table view. - Ngo – Ashish Kakkad May 25 '15 at 10:01
-
1@NgoYenSern the reason is because the UI is loaded into the watch and the code runs on an extension on your phone, so your phone can't send UI updates to the watch. – Schemetrical May 25 '15 at 10:08
-
-
No problem. It might make sens to edit the question to make it more board so more people can see it. Maybe something like "programmatically add WKInterfaceLabel to Apple Watch" – Mika May 25 '15 at 11:01
-
@Mika Now i try to identify which button in the row loop is pressed, I had tried to get the title but can't, anyway you may help me ? – Ngo Yen Sern Jun 30 '15 at 10:13
-