objective-cxcodewatchkitwkinterfacelabelsetuserinteractionenabled

WatchKit User Interaction with a Label


While programming an app to time speeches, I realized that I wanted to be able for a person to pause the timer whenever they would like by simply tapping on the timer (a simple WKInterfaceLabel that updates). I already know how to create a timer and how to pause it within a method, but I can't seem to figure out how to tap the WKInterfaceLabel and create an Action for it.

On iOS I could simply set the userInteractionEnabled property to YES for a UILabel, but it seems that property doesn't exist on WKInterfaceLabel, bringing up the question of how I can have a user simply tap on the label to execute some code.

I was just wondering if anyone has a workaround for this because on Apple's developer's documentation I couldn't find a property that does something similar.


Solution

  • You could try creating a grouped WKInterfaceButton. That way, you can embed the label inside the button itself.