我正在使用Parse
创建此 TableView ,并试图弄清楚如何获取表数据,以便我可以将其传递到WatchKit InterfaceController
.
(我是否需要查询 Parse
以某种方式获取数据并将其存储在 array
中,然后我就可以从 WatchKit InterfaceController
awakeWithContext
?)
这是我的所有内容,如果我可以添加任何有用的内容,请告诉我:
TableVC.m
:
- (id)initWithCoder:(NSCoder *)aCoder
{
self = [super initWithCoder:aCoder];
if (self) {
self.parseClassName = @"na";
self.textKey = @"dateTime";
self.pullToRefreshEnabled = YES;
self.paginationEnabled = NO;
}
return self;
}
- (PFQuery *)queryForTable
{
PFQuery *query = [PFQuery queryWithClassName:self.parseClassName];
return query;
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath object:(PFObject *)object
{
static NSString *simpleTableIdentifier = @"RecipeCell";
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:simpleTableIdentifier];
if (cell == nil) {
cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:simpleTableIdentifier];
}
UILabel *homeLabel = (UILabel*) [cell viewWithTag:101];
homeLabel.text = [object objectForKey:@"test"];
UILabel *dateLabel = (UILabel*) [cell viewWithTag:102];
dateLabel.text = [object objectForKey:@"dateTime"];
return cell;
}
解析
数据:
表VC
:
我确实设置了基本的 WKInterfaceTable
,我所需要做的就是让它显示与 TableVC.m
相同的精确数据。
所以我陷入困境的是,我知道我需要在 WKInterfaceTable
中使用某种数组,但在我的 TableVC.m
中我使用 Parse
我无法弄清楚如何/做什么才能让它发生。看起来我可能会在 viewDidLoad 中执行解析查询,以提取相同的相应 test
和 dateTime
以在 WKInterfaceTable
中使用,但是我不知道?
最佳答案
在您的 WatchKit 扩展中,您需要以不同的方式设置表格。在 iOS 上,UITableView 会根据单元格的需要查询您的数据源。在 WatchKit 上,您需要一次将表格的所有数据传递给 WKInterfaceTable
。我不打算在这里详细介绍如何设置你的 table ,因为你可以在这里找到一些很好的信息 https://developer.apple.com/library/prerelease/ios/documentation/General/Conceptual/WatchKitProgrammingGuide/Tables.html .
此外,我建议您在后台执行解析查询,然后在数据返回后更新您的表。
关于ios - 将数据从 Parse tableview 传递到 WatchKit,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28398721/