1

I have a WKInterfaceTable in a WatchKit app. The rows in the table each have an image and a label. On first load of the interface controller, I set up the table either in awakeWithContext or willActivate, and everything works fine. The labels and images show their content as expected. But if I reload the table in response to the user selecting a row, all the images disappear.

I'm using setImageNamed: on the WKInterfaceImage to set an image that is in the WatchKit app bundle. I've tried having the image in the assets file and included in the project separately. What gives?

My code to set and reset the table looks like this:

[self.table setNumberOfRows:self.rowData.count withRowType:@"myRowType"];
for (NSInteger i = 0; i < self.table.numberOfRows; i++)
{
  MyRowClass row = [self.table rowControllerAtIndex:i];
  MyDataClass data = [self.rowData objectAtIndex:i];
  [row.label setTitle:data.title];
  [row.image setImageNamed:@"MyImage.png"];
}
Tom Hamming
  • 10,577
  • 11
  • 71
  • 145
  • I am observing the same behavior with labels: after reloading the table, those labels whose values did not change, are showing default values. Setting the value to `""` right before setting to desired value fixes it. Definitely a bug. – user443854 Mar 12 '15 at 16:13

1 Answers1

3

There is a bug that should be fixed in the next beta. There is a workaround and it's to reset the value just before assigning the new one.

Try this:

[self.table setNumberOfRows:self.rowData.count withRowType:@"myRowType"];
for (NSInteger i = 0; i < self.table.numberOfRows; i++) {
    MyRowClass row = [self.table rowControllerAtIndex:i];
    MyDataClass data = [self.rowData objectAtIndex:i];
    [row.label setTitle:data.title];
    [row.image setImageNamed:nil];
    [row.image setImageNamed:@"MyImage.png"];
}
BalestraPatrick
  • 9,944
  • 4
  • 30
  • 43