heightForRowAtIndexPath adding extra cell separator - iOS Swift

101 views Asked by At

I have set separator to none on these two below table views which works fine until I implement the heightForRowAtIndexPath method. Once I do that, a new separator appears, that doesn't extend all the way to the right like the default separator, and each one has a varying thickness. What's going on and how can I get rid of the new separators?

enter image description here

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

    }

}
0

There are 0 answers