xcodewatchkitwkinterfacetable

Adding new rows to WKInterfaceTable without reloading existing rows


I have a WKInterfaceTable that is populated with data from a json request (text + images), working just fine.

Now I am trying to add new rows to the table with data from a new request. (So let's say, the initial load is 15 rows, and on user request I want to add another 15 rows, resulting in a total of 30 rows.) When I set the new number of rows, all existing rows (with images) are being reset/emptied. This means I have to reload all images instead of only load the images for the new rows.

tableView.setNumberOfRows(newTotalCount, withRowType: "MyRowController")

Is there a way to leave these rows unchanged, and only update the new rows?

Thanks!


Solution

  • Try to use the - insertRowsAtIndexes:withRowType: method of WKInterfaceTable to avoid to fully reload your table.

    Documentation is here: https://developer.apple.com/library/prerelease/ios/documentation/WatchKit/Reference/WKInterfaceTable_class/#//apple_ref/occ/instm/WKInterfaceTable/insertRowsAtIndexes:withRowType: