gpt4 book ai didi

ios - Swift:IBOutlet var UITableView 的延迟实例化

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

我正在尝试对 IBOutlet var UITableView 进行延迟实例化:

 @IBOutlet lazy weak var tableView: UITableView? = {
return UITableView()
}()

但我收到以下错误:

<unknown>:0: error: cannot convert return expression of type 'UITableView?' to return type 'UITableView?'
<unknown>:0: error: cannot assign value of type 'UITableView?' to type 'UITableView??'
<unknown>:0: error: cannot assign value of type 'UITableView?' to type 'UITableView??'

为什么我会收到此错误?

在这种情况下工作得很好:

lazy var viewController: ViewController = {
return ViewController()
}()

最佳答案

以下是将 ui 元素连接到界面构建器的正确方法,请看一下,它应该会有所帮助: https://developer.apple.com/library/content/referencelibrary/GettingStarted/DevelopiOSAppsSwift/ConnectTheUIToCode.html

enter image description here

关于ios - Swift:IBOutlet var UITableView 的延迟实例化,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/48897222/

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