Search code examples
xcodewatchkit

How can I set a fixed height or width of less than 2 points for WKInterfaceGroup?


When I set the height or width of an interface object in the Watch storyboard to 1 point, it is reverted back to 2 after I unselect then select the object again. This is happening with Xcode 6.3.2.

Here is how I set the height for instance:

Setting height to 1 point

And after unselecting then selecting again the object:

Xcode sets it back to 2 points

But I really want a height of 1 point (2 pixels), which the Watch should be able to display.

I am using a WKInterfaceGroup to create a 1-point hight separator. The problem is the same with any number under 2.0 (for instance 0.5 or 1.5 are also reverted to 2.0), so it looks like Xcode storyboard editor does not accept values less than 2.0 somehow for these parameters. I found the same issue with WKInterfaceImage.


Solution

  • I found a simple solution, which is to set the height in code. This is a bit more cumbersome, because this means I need to set up a outlet for the group in my controller code @interface:

    @property (nonatomic, weak) IBOutlet WKInterfaceGroup *separatorGroup;
    

    The outlet should of course be set up also in the storyboard.

    Then in the refresh code, I simply set up the height or width as follows:

        [self.separatorGroup setHeight:1.0];