我只需要检查选择了哪一行来在WKInterfaceController
之间传递数据。这是我的代码,但NSLog没有显示任何内容:
- (void)loadTableData {
NSArray* items = [NSArray arrayWithObjects:@"cell 1 ",@"cell2 ", @"cell 3",@"cell4",nil];
// Configure the table object (self.todoItems) and get the row controllers.
[self.myTable setNumberOfRows:items.count withRowType:@"DinoNameRow"];
NSInteger rowCount = self.myTable.numberOfRows;
// Iterate over the rows and set the label for each one.
for (NSInteger i = 0; i < rowCount; i++) {
// Get the to-do item data.
NSString* itemText = items[i];
// Assign the text to the row's label.
DinoNameRow* row = [self.myTable rowControllerAtIndex:i];
[row.dinoName setText:itemText];
}
}
- (void)table:(WKInterfaceTable *)table didSelectRowAtIndex:(NSInteger)rowIndex {
switch (rowIndex) {
case 0:
NSLog(@"ROW 1");
break;
default:
break;
}
}
答案 0 :(得分:3)
确保......
WKInterfaceTable
已通过IBOutlet连接到您的Storyboard元素。您已覆盖了正确的WKInterfaceController
方法:
override func table(table: WKInterfaceTable, didSelectRowAtIndex rowIndex: Int) {
}
答案 1 :(得分:0)
我在项目中使用的以下代码运行良好。
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.11.3/jquery.min.js"></script>