Home > Software design >  UICollectionViewCell translatesAutoresizingMaskIntoConstraints property warning (iOS 16 , Xcode 14.2
UICollectionViewCell translatesAutoresizingMaskIntoConstraints property warning (iOS 16 , Xcode 14.2

Time:01-27

I am getting an odd compiler message when presenting a totally innocuous alert controller from a tableViewController:

let ac = UIAlertController(title: "Add item", message: nil, preferredStyle: .alert)
ac.addTextField()
let cancelAction = UIAlertAction(title: "Cancel", style: .default) { _ in return }
ac.addAction(cancelAction)
present(ac, animated: true)

The message reads: "Changing the translatesAutoresizingMaskIntoConstraints property of a UICollectionViewCell that is managed by a UICollectionView is not supported, and will result in incorrect self-sizing". I am puzzled, because I am not changing that property anywhere in my code. Also, I find it curious that tracing execution with the debugger shows that the message appears when the alert controller is presented, not when doing anything actually related to the table. This was not happening in Xcode 13. Where could that message be coming from? Can it be safely ignored? Thanks.

CodePudding user response:

This is an internal layout error / warning message.

If you inspect the full message (it will look like this, with different object hex values for you):

[LayoutConstraints] Changing the translatesAutoresizingMaskIntoConstraints property of a
UICollectionViewCell that is managed by a UICollectionView is not supported, 
and will result in incorrect self-sizing. 

View: <_UIAlertControllerTextFieldViewCollectionCell: 0x7f7a6ff1ba70; 
frame = (0 0; 270 24); gestureRecognizers = <NSArray: 0x6000024fb0c0>; 
layer = <CALayer: 0x600002adb1c0>>

If you use Debug View Hierarchy and find that View you'll see that it is a collection view cell inside the alert controller:

enter image description here

You can safely ignore this message.

  • Related