Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

IBInspectable & watchkit

Can I use IBInspectable at the watchKit ? When I mark a string as IBInspectable, I can see and set it at the relevant watchKit App storyboard, but when I set it, it actually does nothing.

like image 380
Roee84 Avatar asked Dec 25 '22 19:12

Roee84


2 Answers

You can't, because for WatchKit they are Interface Objects instead of Views. Apple intentionally uses different terms for them because they are fundamentally different things.

Interface Objects are proxy objects to those actual views in the actual watch app (not your WatchKit Extension). They communicate through WatchKit via Bluetooth to actually manipulate corresponding properties of those actual views on the watch display.

When you set the text of a WKInterfaceLabel, all it does is just to record the change you want to make, then send the changes with other changes in the run loop to the watch as a batch. The Watch OS will take all the information from those proxy objects and actually change the text on the UILabel on the Watch.

Therefore, IBDesignable and IBInspectable won't really work here. Although they are represented in a similar way in Interface Builder, they are really different things.

like image 176
Richard Bao Avatar answered Dec 27 '22 12:12

Richard Bao


In my experience, you can mark properties as IBInspectable and the property will show up in the inspector panel of interface builder. However, as you've noted, it doesn't appear that those values are populated by WatchKit.

like image 22
Mike Swanson Avatar answered Dec 27 '22 12:12

Mike Swanson