由于我将 xCode 6 beta 5 UITableViews
与用于自定义单元格的 nib 文件一起使用,因此仅在左侧显示单元格的一小条条纹,其余部分为灰色。当我打开 View Debugger 时,它说我的 TableView
中有数千个 _UITableViewCellSeperatorViews
。
这是 TableViewController
override func viewDidLoad() {
super.viewDidLoad()
let nib = UINib(nibName: "TestTableViewCell", bundle: nil)
tableView.registerNib(nib, forCellReuseIdentifier: "newTestCell")
}
override func numberOfSectionsInTableView(tableView: UITableView!) -> Int {
return 1
}
override func tableView(tableView: UITableView!, numberOfRowsInSection section: Int) -> Int {
return 1
}
override func tableView(tableView: UITableView!, cellForRowAtIndexPath indexPath: NSIndexPath!) -> UITableViewCell! {
let cell = tableView.dequeueReusableCellWithIdentifier("newTestCell", forIndexPath: indexPath) as TestTableViewCell
cell.loadData("Test")
return cell
}
这是单元格的类:
@IBOutlet weak var someLabel: UILabel!
func loadData(text: String) {
someLabel.text = text
}
现在我在 View 调试器中得到了 TableView 的图片:
最佳答案
这确实令人费解。这是我修复它的方法:在注册 Nib 后添加
tableView.rowHeight = 44 // or whatever
关于ios - 带有自定义单元格的 UITableView 中的数千个 UITableViewCellSeperatorView,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25352750/