I'm not quite sure what you are asking for, but I set a timer with a button under it in my storyboard for watches. Then I made sure that the timer is enabled with a shortened format (make sure that the second, minute and hour are selected). Make sure the timer is on, otherwise it will not appear in your view, and at present I could not find a way to enable the timer programmatically. Also make sure that you set the date when you pressed the start button, or the timer starts counting without knowing in the background. In the WKInterfaceTimer class, the start method only updates the label and does not actually start any timer. In the code below, the timer is counted from 0.
#import "InterfaceController.h" @interface InterfaceController() @property (weak, nonatomic) IBOutlet WKInterfaceTimer *testTimer; @end @implementation InterfaceController - (instancetype) initWithContext: (id) context { self = [super initWithContext:context]; if (self) { NSLog(@"Custom init called for InterfaceController!"); } return self; } - (void) willActivate { [self.testTimer stop]; NSLog(@"Activated!"); } - (IBAction) onStartButtonPressed { [self.testTimer setDate:[NSDate dateWithTimeIntervalSinceNow:-1]]; [self.testTimer start]; NSLog(@"Start button pressed!"); } @end
The reason the timer stops in the willActivate file is because it will not start counting up as soon as the view is displayed.
source share