An object that provides information that is common to all interface objects in your watchOS app.
- iOS 8.2+
- watchOS 2.0+
Your WatchKit extension uses interface objects to manipulate the visual elements displayed on Apple Watch. Specifically, you use the methods of this class to change the size, alignment, and visibility of those elements. You can also configure the accessibility information displayed through assistive technologies like VoiceOver.
Do not subclass or create instances of this class, or any of its subclasses, yourself. Instead, define outlets in your interface controller class and connect them to the corresponding objects in your storyboard file. For example, to refer to a button in your interface, define a property with the following syntax in your interface controller class:
At runtime, WatchKit creates the appropriate interface objects and assigns them to the outlets in your interface controller.
Communication between an interface object in your extension and the corresponding interface element in your Watch app is one way. You can set the values of an interface object, but you cannot get the current values. If you want to know the current value of an attribute, you must save the value yourself.
Additional Information for watchOS 1
In watchOS 1, calling a setter method on an interface object has performance and latency implications for your app. All data must be transmitted wirelessly to the user’s Apple Watch before the corresponding interface elements can be updated. To minimize the performance impact, WatchKit coalesces the data from all setter method calls made during the same run loop iteration and transmits that data to the user’s Apple Watch at the end of the run loop. If you set an attribute to different values in the same run loop iteration, only the last value is transmitted. If you set an attribute to the same value in the same run loop iteration, WatchKit generates a log message so that you can track down the duplicate change.
Interface Builder Configuration Options
Xcode lets you configure information about your group interface object in your storyboard file. Table 1 lists the attributes you can configure in your storyboard and their meaning.
The opacity of the object. A value of
A checkbox indicating whether the item is hidden initially. You can change the visibility of the item programmatically by calling the
A checkbox indicating whether the item is installed for the current device.
The horizontal alignment of the item. Use this attribute to configure the horizontal position of the item relative to its immediate parent.
The vertical alignment of the item. Use this attribute to configure the vertical position of the item relative to its immediate parent.
The width of the object. Specify a fixed width or set the value of the object to be a percentage of its container’s width.
The height of the object. Specify a fixed height or set the value of the object to be a percentage of its container’s height.