• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

ios - 在 WKInterfaceTable 的选择行上将数据传输到 Iphone

[复制链接]
菜鸟教程小白 发表于 2022-12-12 15:06:06 | 显示全部楼层 |阅读模式 打印 上一主题 下一主题

我正在为 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/

回复

使用道具 举报

懒得打字嘛,点击右侧快捷回复 【右侧内容,后台自定义】
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

关注0

粉丝2

帖子830918

发布主题
阅读排行 更多
广告位

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap