iOS Swift和reloadRowsAtIndexPaths编译错误 [英] iOS Swift and reloadRowsAtIndexPaths compilation error
问题描述
我已经用xCode/Swift陷入僵局,并刷新了UITableView的一行.
I've hit deadlock with xCode/Swift and refreshing a single row of UITableView.
此行有效....
self.tableView.reloadData();
此行不
self.tableView.reloadRowsAtIndexPaths([_currentIndexPath], withRowAnimation: UITableViewRowAnimation.None);
自动完成建议 reloadRowsAtIndexPaths 并给出语法,但是在编译时,出现错误:
Auto-complete is suggesting reloadRowsAtIndexPaths and giving the syntax but on compilation, I'm getting the error:
找不到成员'reloadRowsAtIndexPaths".
'Could not find member 'reloadRowsAtIndexPaths'.
如果我右键单击self.tableview
中的"jump to definition
",则找不到该符号.
If I right click and 'jump to definition
' in self.tableview
, the symbol is not found.
我希望我在这里不会做任何令人尴尬的愚蠢工作,希望能有所帮助.我可以使用reloadData
,但想知道为什么这在这里不起作用.
I'm hoping I'm not doing anything embarrassingly stupid here and would appreciate help. I could use reloadData
but want to know why this isn't working here.
推荐答案
我相信_currentIndexPath
是可选的.像
var _currentIndexPath:NSIndexPath?
所以尝试:
if let indexPath = _currentIndexPath {
self.tableView.reloadRowsAtIndexPaths([indexPath], withRowAnimation: UITableViewRowAnimation.None)
}
else {
// `_currentIndexPath` is nil.
// Error handling if needed.
}
这篇关于iOS Swift和reloadRowsAtIndexPaths编译错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!