Rawling
Rawling

Reputation: 50204

WKInterfaceTable shows storyboard data when adding rows

I have a WKInterfaceTable with a single row controller. I am using the following code to bind data to the table:

[self.table setNumberOfRows:[data count] withRowType:@"RowController"];
for (int i = 0; i < [data count]; i++)
{
    RowController *row = [self.table rowControllerAtIndex:i];
    [row bind:[data objectAtIndex:i]]; // sets labels in the row etc.
}

I have the same problem if I add rows one-by-one using insertRowsAtIndexes:withRowTypes:. In either case, you have to first add a row to the table before you can update the row to show the correct data.

The first issue is that, because of this, the user gets to see the dummy storyboard data in between the row being added and the data being bound to it.

I've tried

Is there really no way to render a table row before displaying it to the user?

Upvotes: 1

Views: 380

Answers (1)

anon
anon

Reputation:

I had a similar problem, which was solved by dispatching a job onto the main thread.

dispatch_async(dispatch_get_main_queue(), ^{
    [self.table setNumberOfRows:[data count] withRowType:@"RowController"];
    for (int i = 0; i < [data count]; i++)
    {
        RowController *row = [self.table rowControllerAtIndex:i];
        [row bind:[data objectAtIndex:i]]; // sets labels in the row etc.
    }
});

Upvotes: 3

Related Questions