OGeek|极客世界-中国程序员成长平台

标题: ios - 在 WKInterfaceTable 的选择行上将数据传输到 Iphone [打印本页]

作者: 菜鸟教程小白    时间: 2022-12-12 15:06
标题: ios - 在 WKInterfaceTable 的选择行上将数据传输到 Iphone

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

- (void)configureTableWithDataNSArray*)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)tableWKInterfaceTable *)table didSelectRowAtIndexNSInteger)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 上打印,当然我什么也没得到。 (对不起我的英语,不是我的母语)我错过了什么?



Best Answer-推荐答案


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

- (void)tableWKInterfaceTable *)table didSelectRowAtIndexNSInteger)rowIndex {

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

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

     [self dismissController];
}

关于ios - 在 WKInterfaceTable 的选择行上将数据传输到 Iphone,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29714489/






欢迎光临 OGeek|极客世界-中国程序员成长平台 (http://ogeek.cn/) Powered by Discuz! X3.4