ioswatchkitapple-watchwkinterfacetable

Watchkit: table with two templates in dynamic rows


How to instantiate two different templates of dynamic row in WKInterfaceTable? For only one template I use functions

 [self.stocksTable setNumberOfRows: self.stocksData.count withRowType:@"TableRow"];
 TableRow *row = [self.stocksTable rowControllerAtIndex:i];

Question: How to have 2 types of row?


Solution

  • You want -[WKInterfaceTable setRowTypes:]:

    [self.myTable setRowTypes:@[@"RowType1", @"RowType2"]];
    MyRowType1Controller *row1 = [self.myTable rowControllerAtIndex:0];
    MyRowType2Controller *row2 = [self.myTable rowControllerAtIndex:1];