【问题标题】:On select row of WKInterfaceTable transfer data to Iphone在 WKInterfaceTable 的选择行上将数据传输到 Iphone
【发布时间】:2015-04-18 07:45:29
【问题描述】:

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

【问题讨论】:

    标签: ios objective-c watchkit apple-watch wkinterfacetable


    【解决方案1】:

    我对 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];
    }
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2014-01-20
      • 1970-01-01
      • 1970-01-01
      • 2011-08-21
      • 2016-01-13
      • 2018-02-15
      • 1970-01-01
      • 2012-04-12
      相关资源
      最近更新 更多