【问题标题】:iOS Swift and reloadRowsAtIndexPaths compilation erroriOS Swift 和 reloadRowsAtIndexPaths 编译错误
【发布时间】:2015-02-06 01:26:56
【问题描述】:

我在使用 xCode/Swift 并刷新了一行 UITableView 时遇到了死锁。

这条线有效....

self.tableView.reloadData();

而这条线没有

self.tableView.reloadRowsAtIndexPaths([_currentIndexPath], withRowAnimation: UITableViewRowAnimation.None);

自动完成提示 reloadRowsAtIndexPaths 并给出语法,但在编译时,我收到错误:

'找不到成员'reloadRowsAtIndexPaths'。

如果我右键单击并在self.tableview 中单击“jump to definition”,则找不到该符号。

我希望我没有在这里做任何令人尴尬的愚蠢事情,并希望得到帮助。我可以使用reloadData,但想知道为什么这在这里不起作用。

【问题讨论】:

  • 我完全按照您的意愿使用它:self.tableView.reloadRowsAtIndexPaths([indexPath], withRowAnimation: .None) 没有问题。
  • ...令人放心。这是一个奇怪的!

标签: ios uitableview swift reload


【解决方案1】:

我相信,_currentIndexPath 是可选的。像

var _currentIndexPath:NSIndexPath?

那就试试吧:

if let indexPath = _currentIndexPath {
    self.tableView.reloadRowsAtIndexPaths([indexPath], withRowAnimation: UITableViewRowAnimation.None)
}
else {
    // `_currentIndexPath` is nil.
    // Error handling if needed.
}

【讨论】:

  • #rintaro。谢谢...完美运行。所以我的下一个问题是……为什么?
  • 什么是理想的放置位置。它会在这里... func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell { .... OR in viewDidAppear( ) 等
猜你喜欢
  • 2019-08-23
  • 1970-01-01
  • 1970-01-01
  • 2013-11-04
  • 1970-01-01
  • 1970-01-01
  • 2017-06-07
  • 2017-10-13
  • 2017-03-23
相关资源
最近更新 更多