Aecasorg
Aecasorg

Reputation: 165

SwipeCellKit not swiping

I can't get my cells to swipe using SwipeCellKit. The code is below and I suspect it is the cell.delegate row, however I seem to be blind to the problem. I am assuming it will be immediately obvious to someone else.

Note: CharacterTableViewCell is a SwipeTableViewCell class.

Any help would be really appreciated.

func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {

    let cell = tableView.dequeueReusableCell(withIdentifier: "Cell", for: indexPath) as! CharacterTableViewCell

    cell.delegate = self as? SwipeTableViewCellDelegate

    if let char = chars?[indexPath.row] {

        let formattedString = NSMutableAttributedString()

        formattedString
            .normal("\(char.charName) - iLevel: ")
            .bold("\(char.averageItemLevelEquipped)")
            .normal("\n\(classConverter(class: (char.charClass))) - \(char.spec) (\(char.role))\nMissing gems: \(char.emptySockets)\nEnchants: \(char.backEnchant)")

        cell.characterDataLabel.attributedText = formattedString

        cell.characterThumbnail.layer.cornerRadius = 20
        cell.characterThumbnail.layer.masksToBounds = true

        cell.characterThumbnail.downloadedFrom(link: "http://render-eu.worldofwarcraft.com/character/\(char.thumbnail)")

        cell.characterBackground.backgroundColor = UIColor(hex: classColor(class: char.charClass))

    }

    return cell
}

Upvotes: 3

Views: 602

Answers (1)

Aecasorg
Aecasorg

Reputation: 165

Thanks to @Dharmesh Kheni and the answers from Delegate Method to UItableViewCell Swift I worked out the issue.

Instead of having cell.delegate = self as? SwipeTableViewCellDelegate I moved the SwipeTableViewCellDelegate up to

extension ViewController: UITableViewDataSource, UITableViewDelegate, SwipeTableViewCellDelegate {

That solved it. I knew it was an obvious answer! ;)

Upvotes: 1

Related Questions