【问题标题】:Is there a way to reload data in UITableViewController using RubyMotion?有没有办法使用 RubyMotion 在 UITableViewController 中重新加载数据?
【发布时间】:2014-03-19 23:49:52
【问题描述】:

我有一个UITableViewController,但我在它上面展示了一个模态控制器。当模态控制器关闭时,我再次看到UITableViewController。此时我想重新加载UITableViewController中的数据

示例场景

  1. UITableViewController 配红蓝绿
  2. 显示带有文本字段的模态控制器。在文本字段中输入 Yellow 并单击一个按钮。单击按钮时,模态控制器被关闭,UITableViewController 重新出现
  3. 重新加载UITableViewController 以显示红色蓝色绿色黄色

这可能吗?

【问题讨论】:

  • 该函数称为 reloadData 大声笑。但如果表有大量数据,您可能需要阅读 reloadRows。

标签: ios iphone ios7 uitableview rubymotion


【解决方案1】:

这应该超级简单:

// assuming this is somewhere in your UITableViewController implementation:
[self.tableView reloadData];

我假设如果下面的链接是准确的,那么 RubyMotion API 中存在完全相同的方法名称:

http://www.rubymotion.com/developer-center/api/UITableView.html#reloadData-instance_method

额外的 S.O.已经有一个非常相似的帖子只重新加载表格视图的某些部分:

RubyMotion reload sections of UITableView

【讨论】:

  • 我是新手。试图找出如何在 ruby​​motion 中做到这一点
  • 那是另一个问题。
  • 迅速:self.tableView.reloadData()
【解决方案2】:

代码是[tableView reloadData];,但问题是你怎么知道模态已经解除了。如果你做的事情是正确的,并且你正在从呈现的 viewController 中解散模式,那很容易:

[self dismissViewControllerAnimated:NO completion:^{
    [tableView reloadData];
}];

如果你不是,那么你需要将呈现视图控制器设置为模态的委托,并在关闭时执行一个重新加载数据的函数。

【讨论】:

  • 我是新手。试图找出如何在 ruby​​motion 中做到这一点
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 2021-12-25
  • 2013-08-21
  • 2018-07-31
  • 1970-01-01
  • 1970-01-01
  • 2021-08-25
  • 1970-01-01
相关资源
最近更新 更多