在我的视图控制器中,我有一个具有计数器数据功能的标签,该计数器数据由Parse.com的PFQuery调用。这些数据可能随时更改。

我需要在数据浏览器中的数据更改时自动更新此标签,即使用户不在应用程序中也是如此。

假设我需要对TableView进行某种类型的标签自动重装。我能怎么做?有人知道正确的方法吗?

最佳答案

非常简单,假设您的单元格中有一个pfLabel

通过以下委托方法实现查询:

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath     *)indexPath {
 ..................
 // Do stuff here.
 PFQuery *yourQuery = [PFQuery queryWithClassName:@"YOUR_PARSE_CLASS_NAME"];
 // Implement your query constraint here, after that, get your desired data and show it using your desired label
[yourQuery findObjecsInBackgroundWithBlock:^(NSString* obj) {
    pfLabel.text = obj;
}];
// Congrat, you just have your label asynchronously showed your parse data.
.....................
}

关于ios - 自动重新加载UiLabel数据,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/19569929/

10-16 14:09