Why is WKInterfaceLabel text not refreshing

268 Views Asked by At

The WatchApp receives data from the iPhone.

I refresh the label text with the data received, nothing happens, the UI is not refreshing.

Other threads suggested pushing it to the main thread and that seems to do nothing either.

Any thoughts most welcome.

-(void)session:(nonnull WCSession *)session didReceiveApplicationContext:(nonnull NSDictionary *)applicationContext

{
    dispatch_async(dispatch_get_main_queue(), ^{
    [self.lblTitleBorH setText:@"test"];
    });
}
2

There are 2 best solutions below

1
JackyW On

Are you using

    [*your session* updateApplicationContext:*your dictionary* error:nil];

correctly?

try putting a NSLog inside your above didReceiveApplicationContext code and see if it is printing anything out.

0
Enrico Cupellini On

In my case, when I tried to refresh the UI, I found that the outlet references were nil. The problem was caused by two interfaces on the storyboard, belonging to the same WKInterfaceController class. When I assigned the second screen interface to another WKInterfaceController class it worked fine.

enter image description here

remember to call the UI objects from the main thread by using

dispatch_async(dispatch_get_main_queue(), ^{
   ...
});

or by using methods like performSelectorOnMainThread: withObject: waitUntilDone: