Search code examples
iosautolayoutuikitios15xcode13

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 🙏


Solution

  • 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.sstatic.net/bDSJ3.png