简体   繁体   English

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

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

I'm running into an odd error. 我遇到了一个奇怪的错误。 This line of code functions correctly: 这行代码可以正常运行:

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

However when I cast to FeedCell! 但是,当我投射到FeedCell! (a subclass of UITableViewCell ): UITableViewCell的子类):

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

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

I'm not sure how it can be ambiguous, let alone triggered by a different casting! 我不确定它是如何模棱两可的,更不用说是由其他转换触发的!

Try changing the line to 尝试将行更改为

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

Just remove the ! 只需删除! from FeedCell! 来自FeedCell! and put it in as! 并放入as! and check if there is any difference. 并检查是否有任何差异。

Beside as @redent84 mentioned in his comment you should use tableView instead of self.tableView . 除了在他的评论中提到的@ redent84之外,您还应该使用tableView而不是self.tableView

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

相关问题 对成员“tableView(_:numberOfRowsInSection:)”的不明确引用 - Ambiguous reference to member 'tableView(_:numberOfRowsInSection:)' 'NSInternalInconsistencyExceptionException'原因:将表视图单元出队时,“无法在捆绑包中装载NIB” - 'NSInternalInconsistencyException' reason: 'Could not load NIB in bundle' when dequeuing tableview cell 对成员'tableView(_:numberOfRowsInSection :)'的模糊引用为什么会出现此错误? - Ambiguous reference to member 'tableView(_:numberOfRowsInSection:)' Why this error? 使用RxSwift对成员'tableView'的不明确引用 - Ambiguous reference to member 'tableView' using RxSwift tableView.reloadData()错误:对成员的引用不明确 - tableView.reloadData() error: Ambiguous reference to member 使用ceil或round时对成员的模糊引用 - Ambiguous reference to member when using ceil or round 使用FBSDKApplicationDelegate时对成员“下标”的引用不明确 - Ambiguous reference to member 'subscript' when using FBSDKApplicationDelegate 使用UIApplicationShortcutItem时对成员“下标”的引用不明确 - Ambiguous Reference To Member 'Subscript' when using UIApplicationShortcutItem 对成员Swift 3的模糊引用 - Ambiguous reference to member Swift 3 成员'计数'含糊不清 - Ambiguous reference to member 'count'
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM