Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

When isEditing is true, my texts are not aligned as seen in the picture. What is the reason?

Important : Tableview constraints codes are in a separate file.

enter image description here

Edit Button Code

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

    @objc func didTapEdit(){
    if plansListTableView.isEditing {
        plansListTableView.isEditing = false
    }
    else {
        plansListTableView.isEditing = true
        
    }
}

Constraints Code

    private func addConstraints(){
    addSubview(planLabel)
        NSLayoutConstraint.activate([
            planLabel.centerYAnchor.constraint(equalTo: centerYAnchor),
            planLabel.leadingAnchor.constraint(equalTo: safeAreaLayoutGuide.leadingAnchor, constant: 20)
        ])
}

>Solution :

Add the label to contentView

private func addConstraints(){
    contentView.addSubview(planLabel)
    NSLayoutConstraint.activate([
        planLabel.centerYAnchor.constraint(equalTo: contentView.centerYAnchor),
        planLabel.leadingAnchor.constraint(equalTo: contentView.leadingAnchor, constant: 20)
    ])
}

And shortly

plansListTableView.isEditing.toggle()
Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading