gpt4 book ai didi

swift - Xcode 一次又一次地显示错误“你想在 Swift 中添加协议(protocol) stub 吗?”

转载 作者:行者123 更新时间:2023-11-30 11:34:11 26 4
gpt4 key购买 nike

我使用的是 Xcode 9.2。我正在为我的表格 View 添加可扩展效果。我在 viewDidLoad 中设置了委托(delegate),并为可扩展委托(delegate)协议(protocol)扩展了 View Controller 。

我的问题是 Xcode 显示“您想添加协议(protocol) stub 吗?”一次又一次的错误消息,我已经通过单击“修复它”按钮添加了两次。

谁能告诉我我错过了什么?

class MenuController: UIViewController,MFMailComposeViewControllerDelegate {

var coverView = UIView()

@IBOutlet weak var tblViewMenu: ExpandableTableView!

override func viewDidLoad() {
super.viewDidLoad()
revealViewController().revealToggle(animated: false)

tblViewMenu.expandableDelegate = self as! ExpandableTableViewDelegate
tblViewMenu.register(UINib(nibName: "ExpandCell1", bundle: nil), forCellReuseIdentifier: "ExpandCell1")
}
}

扩展

extension MenuController: ExpandableDelegate {

func expandableTableView(_ expandableTableView: ExpandableTableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
let cell:ExpandCell1 = tblViewMenu.dequeueReusableCell(withIdentifier: "ExpandCell1") as! ExpandCell1
cell.textLabel?.text = "TableViewCellMain"
return cell
}

func expandableTableView(_ expandableTableView: ExpandableTableView, numberOfRowsInSection section: Int) -> Int {
return 5
}

func expandableTableView(_ expandableTableView: ExpandableTableView, heightForRowAt indexPath: IndexPath) -> CGFloat {
return 44
}

func expandableTableView(_ expandableTableView: ExpandableTableView, expandedCellsForRowAt indexPath: IndexPath) -> [UITableViewCell]? {
let cell:CellTableView1 = tblViewMenu.dequeueReusableCell(withIdentifier: "CellTableView1") as! CellTableView1
cell.textLabel?.text = "CellTableView1"
return [cell]
}

func expandableTableView(_ expandableTableView: ExpandableTableView, heightsForExpandedRowAt indexPath: IndexPath) -> [CGFloat]? {
return [200]
}

func numberOfSections(in tableView: ExpandableTableView) -> Int {
return 1
}

func expandableTableView(_ expandableTableView: ExpandableTableView, didSelectRowAt indexPath: IndexPath) {
// print("didSelectRow:\(indexPath)")
}

func expandableTableView(_ expandableTableView: ExpandableTableView, didSelectExpandedRowAt indexPath: IndexPath) {
// print("didSelectExpandedRowAt:\(indexPath)")
}

func expandableTableView(_ expandableTableView: ExpandableTableView, expandedCell: UITableViewCell, didSelectExpandedRowAt indexPath: IndexPath) {

}

func expandableTableView(_ expandableTableView: UITableView, shouldHighlightRowAt indexPath: IndexPath) -> Bool {
return true
}

func expandableTableView(_ expandableTableView: UITableView, didUnhighlightRowAt indexPath: IndexPath) {

}
}

屏幕截图

screenshot of the error

最佳答案

这是一个 Xcode 错误。该项目将正确构建并运行,但错误仍然存​​在。如果您想消除错误,请清理项目。如果这没有帮助,请退出 Xcode 并 delete the DerivedData folder .

关于swift - Xcode 一次又一次地显示错误“你想在 Swift 中添加协议(protocol) stub 吗?”,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/49938639/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com