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 
} 
相关问题