我在这两个下面的表视图中将separator设置为none,这在我实现heightForRowAtIndexPath
方法之前一直正常。一旦我这样做,就会出现一个新的分隔符,它不像默认分隔符那样一直延伸到右边,每个分隔符都有不同的厚度。发生了什么,如何摆脱新的分隔符?
func tableView(_ tableView: UITableView, heightForRowAt indexPath: IndexPath) -> CGFloat {
if tableView == editsTableView {
return 44.0
} else if tableView == selectionTableViewLeft || tableView == selectionTableViewRight {
let h = selectionTableViewLeft.frame.size.height / CGFloat(leftOptions.count)
if h > 44.0 {
return h
} else {
return 44.0
}
} else {
return 44.0
}
}
func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
if tableView == selectionTableViewLeft {
return leftOptions.count
} else if tableView == selectionTableViewRight {
return rightOptions.count
} else {
return edits.count
}
}
func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
if tableView == editsTableView {
let cell = tableView.dequeueReusableCell(withIdentifier: "editCell")!
if indexPath.row == 0 {
cell.textLabel?.text = "Issued by \(String(describing: edits[indexPath.row].name))"
} else {
cell.textLabel?.text = "Edited by \(String(describing: edits[indexPath.row].name))"
}
cell.detailTextLabel?.text = GlobalFunctions.shared.formattedTimestamp(ts: edits[indexPath.row].timeStamp, includeDate: true, includeTime: true)
return cell
} else {
var currentOptions: [String] = []
if tableView == selectionTableViewLeft {
currentOptions = leftOptions
} else {
currentOptions = rightOptions
}
let cell = tableView.dequeueReusableCell(withIdentifier: "cell")! as UITableViewCell
colorCell(text: currentOptions[indexPath.row], cell: cell)
cell.textLabel?.font = UIFont.systemFont(ofSize: 20.0)
cell.textLabel?.textAlignment = .center
if currentOptions[indexPath.row] == "(Blank)" {
cell.textLabel?.attributedText = GlobalFunctions.shared.italic(string: "(Blank)", size: 20.0, color: .lightGray)
} else {
cell.textLabel?.text = currentOptions[indexPath.row]
}
return cell
}
}