“Button” text appears on the UIButton when pressed

Issue

This Content is from Stack Overflow. Question asked by AbheshekSharma

I am using two buttons inside a TableViewCell. I am using system images for both of them. I have removed the Title from both of them as I don’t want any text, only image. But when I click them, the text ‘Button’ which is the default title, appears again.

How to do I solve this?

import UIKit

class scheduleCell: UITableViewCell {

    override func awakeFromNib() {
        super.awakeFromNib()
        editBtn.titleLabel?.text = ""
        deleteSchedule.titleLabel?.text = ""
    }

    @IBOutlet weak var timeLabel1: UILabel!
    
    @IBAction func edit(_ sender: Any) {
        
        
        print("EDIT BTN ")
        
    }
    @IBOutlet weak var timeLabel2: UILabel!
    
    @IBOutlet weak var editBtn: UIButton!
    
    @IBOutlet weak var deleteSchedule: UIButton!
    
    @IBAction func deleteBtn(_ sender: Any) {
        
        print("DELETE BTN ")
    }
    
    override func setSelected(_ selected: Bool, animated: Bool) {
        super.setSelected(selected, animated: animated)
        timeLabel1.text = ""
        timeLabel2.text = ""
       
    }
    
}



Solution

Check the Answers

This Question and Answer are collected from stackoverflow and tested by JTuto community, is licensed under the terms of CC BY-SA 2.5. - CC BY-SA 3.0. - CC BY-SA 4.0.

people found this article helpful. What about you?