我在故事板与tableview中这样的视图控制器:子类有IBOutlet中泰伯维斯威夫特
它的阶级是这样的(我联系称为 'tabella' 的IBOutlet中实现代码如下):
class RisultatiRicerca: UIViewController , UITableViewDataSource , UITableViewDelegate{
var codeSearch = 0
@IBOutlet public var tabella : UITableView!
override func viewDidLoad() {
super.viewDidLoad()
self.tabella.estimatedRowHeight = 50
self.tabella.rowHeight = UITableViewAutomaticDimension
self.tabella.delegate = self
self.tabella.dataSource = self
self.tabella.reloadData()
}
@available(iOS 2.0, *)
func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
let cella = tableView.dequeueReusableCell(withIdentifier: "risu") as! CellaRisultato
return cella
}
@available(iOS 2.0, *)
public func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int{
return 10
}
}
我的问题是这样的:
我要创建的这个子类上面,比如这个:
class TuttiRicerca: RisultatiRicerca {
override func viewDidLoad() {
super.viewDidLoad()
self.codeSearch = 1
}
}
但是当我提出的TuttiRicerca
我得到这个错误(“tabella”是无):
这就像子犯规情节板中的链接实现代码如下。 你能帮我吗?
你要么失败挂钩出口在故事板,或者,如果你以编程的方式实例化了这个视图控制器,你做得不对,所以检查IB的出口,如果你以编程方式转换到这个场景,那么我们用你的代码 – Rob
在故事板中,我只有控制器关于' RisultatiRicerca'类,它的出口是链接的。我没有控制器关于它的子类 – gianni
istanciate'TuttiRicerca'控制器我只是这样做的:public let viewController1:TuttiRicerca = TuttiRicerca ) – gianni