【发布时间】:2021-04-15 00:42:18
【问题描述】:
我是新来的,没有其他地方可以问这个问题,所以我为我在这个问题中的格式道歉。
所以我不小心在 Main.Storyboard 上编辑了我的 UITableView(我不小心删除了我的 1 个也是唯一的原型单元格),当我试图放回原型单元格并重新连接我的 UITableViewCell 变量时,它现在给了我这个错误:
“从 SettingsViewController 到 UITableViewCell 的 dropDownCurrCell 出口无效。出口无法连接重复内容。”
我有这个代码
class SettingsViewController: UIViewController, UITableViewDataSource, UITableViewDelegate {
func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
return listCurrencies.count
}
//listing the cell for the supported currencies
func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
let listCell = tableView.dequeueReusableCell(withIdentifier: "supportedCurrencies", for: indexPath)
listCell.textLabel!.text = String( listCurrencies[indexPath.row].currName)
return listCell
}
和
@IBOutlet var dropDownCurr: UITableView!{
didSet {
dropDownCurr.dataSource = self
dropDownCurr.delegate = self
}
}
@IBOutlet weak var dropDownCurrCell: UITableViewCell!
你们怎么了?我刚开始尝试学习 Swift。
【问题讨论】:
-
您不会将表格单元实例连接到视图控制器中的插座。删除
dropDownCurrCell出口。单元格有一个单元格标识符,您可以在cellForRow(at:)中使用它来创建单元格实例 -
在 .swift 和情节提要上?
-
您将原型单元保留在情节提要中,但您不会创建任何从它到视图控制器的出口。如果您有该原型单元格的
UITableViewCell子类,那么您将单元格的内容(标签、文本字段等)链接到单元格子类中的插座 -
我已经删除了视图控制器中原型单元的出口,并将原型单元保留在我的故事板上,但我仍然有同样的错误。如果我误解了这一点,我很抱歉。
-
它告诉您您正在尝试将原型单元(或单元本身)中的项目链接(或已链接)到视图控制器类中的出口。