Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Must translate autoresizing mask into constraints to have _setHostsLayoutEngine:YES Xcode 13

I have updated my project to Xcode 13 and iOS 15. Now the app is crashing with an error related to autoresizing masks in UITableViewCells. I have tried to change UITableViewCells Layer property in the inspector to Inferred and followed this post, but none of them are working.

Have you encountered this problem. How it could be fixed?

Here is some information about the error:

Error Image

Interface Builder Config Image

override func awakeFromNib() {
    super.awakeFromNib()
    selectionStyle = .none
    setupEventAction()
    configureAccessibilityForCellItem()
}

override func prepareForReuse() {
    super.prepareForReuse()
    eventView.eventImageView.image = nil
}

func configureAnnouncement(announcement: AnnouncementsRowItem, isWhiteCell: Bool = false) {
    eventView.isHidden = announcement.event == nil
    eventView.backgroundView.backgroundColor = isWhiteCell ? R.color.basic1_bg() : R.color.basic2_bg()
    if announcement.event?.eventID.isEmpty ?? false || !isWhiteCell {
        self.backgroundColor = R.color.basic2_bg()
    }
    bubbleView.configureAnnouncementsBubbleView(announcement: announcement)
    eventView.configureAnnouncementsEventView(announcement: announcement)
    layoutIfNeeded()
}

private func setupEventAction() {
    eventView.isUserInteractionEnabled = true
    let gesture = UITapGestureRecognizer(target: self, action: #selector(showEvent))
    gesture.numberOfTapsRequired = 1
    eventView.addGestureRecognizer(gesture)
}

@objc
func showEvent() {
    openEventClicked?()
}

Thanks 🙏

like image 572
conradomateu Avatar asked Oct 01 '21 11:10

conradomateu


2 Answers

I have faced up with same problem. Try following: Open *.xib of your UITableViewCell as source code (Context menu / "Open As" / "Source Code"). Locate "tableViewCell" and "tableViewCellContentView" tags, delete its "translatesAutoresizingMaskIntoConstraints" attributes (with values), delete its subtags "autoresizingMask" if present.

https://i.stack.imgur.com/bDSJ3.png

like image 165
overall63 Avatar answered Oct 21 '22 21:10

overall63


My issue was resolved with a different solution, while the error was the same the cause was different. A view inside my cell was assigned the same class from the cell, by removing the class the error was resolved. View inside TableViewCell with same class as TableViewCell

like image 27
Javier Heisecke Avatar answered Oct 21 '22 22:10

Javier Heisecke