我有一个 WKInterfaceTable 开始隐藏(因为它在我的原始代码中从服务器检索信息),当表格被填满时,我只是显示它并且第一行开始折叠。
这里有 willActivate 代码。
- (void)willActivate {
// This method is called when watch view controller is about to be visible to user
[super willActivate];
[self.myTable setNumberOfRows:10 withRowType:@"MyCell"];
for (int i = 0; i < self.myTable.numberOfRows; i++) {
MyCell * cell = [self.myTable rowControllerAtIndex:i];
[cell.myTitle setText:@"My title"];
}
[self.myTable setHidden:NO];
}
更新我发现如果我在发送到主队列的块上填充表,它可以解决问题。
- (void)willActivate {
// This method is called when watch view controller is about to be visible to user
[super willActivate];
[self.myTable setHidden:NO];
dispatch_async(dispatch_get_main_queue(), ^{
[self.myTable setNumberOfRows:10 withRowType:@"MyCell"];
for (int i = 0; i < self.myTable.numberOfRows; i++) {
MyCell * cell = [self.myTable rowControllerAtIndex:i];
[cell.myTitle setText:@"My title"];
}
});
}