我在故事板與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