我正在为 iOS 应用程序制作 watch 应用程序。我从监视主 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 上打印,当然我什么也没得到。 (抱歉我的英语,不是我的母语)我错过了什么?
最佳答案
我在表格 View 中的 watch 套件上遇到了同样的问题。目前我们只设置单元格标签中的文本而不返回,所以你必须这样做
- (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];
}
关于ios - 在 WKInterfaceTable 的选择行上将数据传输到 Iphone,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29714489/