繁体   English   中英

使单元出队时对成员“ tableView”的不明确引用

[英]Ambiguous reference to member 'tableView' when dequeuing a cell

我遇到了一个奇怪的错误。 这行代码可以正常运行:

let cell = self.tableView.dequeueReusableCellWithIdentifier("FeedCell", forIndexPath: indexPath) as UITableViewCell!

但是,当我投射到FeedCell! UITableViewCell的子类):

let cell = self.tableView.dequeueReusableCellWithIdentifier("FeedCell", forIndexPath: indexPath) as FeedCell!

Xcode引发错误: Ambiguous reference to member 'tableView'

我不确定它是如何模棱两可的,更不用说是由其他转换触发的!

尝试将行更改为

let cell = tableView.dequeueReusableCellWithIdentifier("FeedCell", forIndexPath: indexPath) as! FeedCell

只需删除! 来自FeedCell! 并放入as! 并检查是否有任何差异。

除了在他的评论中提到的@ redent84之外,您还应该使用tableView而不是self.tableView

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM