2

我正在为 iOS 应用程序制作手表应用程序。我从 watch main InterfaceController 中的父应用程序获取数据并将其传递给其他 InterfaceController 以创建表。这里配置表的代码:

- (void)configureTableWithData:(NSArray*)dataObjects {

    [self.table setNumberOfRows:[dataObjects count] withRowType:@"rowType"];
    for (NSInteger i = 0; i < self.table.numberOfRows; i++) {

        RowType* row = [self.table rowControllerAtIndex:i];
        NSObject* object = [dataObjects objectAtIndex:i];

        [row.titleName setText:[object valueForKey:@"CharCode"]];
        [row.bottomValue setText:[object valueForKey:@"Value"]];
    }
}

当我选择行时,我想将数据传输回第一页。需要更改第一页上的一些标签。我正在将数据传输到父应用程序并将其返回到主 InterfaceController

- (void)table:(WKInterfaceTable *)table didSelectRowAtIndex:(NSInteger)rowIndex {

     //Here must be dictionary, where I put row

     [WKInterfaceController openParentApplication:data reply:^(NSDictionary *replyInfo, NSError *error) {
          NSLog(@"data transfer");
     }];

     [self dismissController];
}

如何获取行数据?(row.titleName, row.value) 可能这是个愚蠢的问题,我仍然只是一个初学者,但我可以得到它。我试图在控制台 row.titleName 和 row.bottomValue 上打印,当然我什么也没得到。(对不起我的英语,不是我的母语)我错过了什么?

4

1 回答 1

3

我对 tableview 中的手表套件有同样的问题。现在我们只设置单元格标签中的文本不回来所以你必须这样做

- (void)table:(WKInterfaceTable *)table didSelectRowAtIndex:(NSInteger)rowIndex {

     //Here must be dictionary, where I put row
     NSDictionary* object = [dataObjects objectAtIndex:rowIndex];
     NSLog("used object as you want");

     [WKInterfaceController openParentApplication:object reply:^(NSDictionary *replyInfo, NSError *error) {
          NSLog(@"data transfer");
     }];

     [self dismissController];
}
于 2015-04-18T09:04:11.927 回答