2

我在UITabBarController的UINavigationController中有一個靜態單元UITableViewController。當連接到自定義類時,單元格消失

當我爲UITableViewController創建一個自定義類並對其進行設置時,UITableView中的所有單元格在構建後消失。我可以在設計師中看到它們,但不能在模擬器或設備中看到。

我是新來的iOS開發人員,如果我犯了一個明顯的錯誤,原諒。

+0

也許我應該設置自定義類的UINavigationController,而不是:如果你有在的UITableViewController一個UINavigationController與否,創建自定義類後,你應該評論或刪除下面的方法,如果你有靜態細胞沒關係UITableViewController但我怎麼可以添加屬性,如果是這樣? – cameloper

+1

顯示您的子類的代碼。 – pbasdf

+0

我發現,你的猜測是對的。由Xcode自動添加的方法阻止顯示我的靜態單元格。謝謝! – cameloper

回答

0

給每個有同樣掙扎的人。

override func numberOfSections(in tableView: UITableView) -> Int { 
    // #warning Incomplete implementation, return the number of sections 
    return 0 
} 

override func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int { 
    // #warning Incomplete implementation, return the number of rows 
    return 0 
} 

override func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell { 
    let cell = tableView.dequeueReusableCell(withIdentifier: "reuseIdentifier", for: indexPath) 

    // Configure the cell... 

    return cell 
} 
相關問題