簡體   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