In our app we have a TableViewController that is vertically flipped by setting tableView.transform = CGAffineTransform(scaleX: 1, y: -1) (and the same is applied to all cells).
We noticed in iOS 14, initially the layout respects the safe area as expected, but after rotating the device it does not update properly, but the same safe area insets as before are applied. So for example when opening the view in portrait and then rotating to landscape, the insets left and right are still 0 and the content is rendered outside the safe area.
When looking at tableView.safeAreaInsets, you can see the values are not updated after rotating, and viewSafeAreaInsetsDidChange() does not get called. The bug can be reproduced with any transformation.
This worked perfectly fine in iOS 13. Is this a bug in UIKit? Is there a workaround?
We noticed in iOS 14, initially the layout respects the safe area as expected, but after rotating the device it does not update properly, but the same safe area insets as before are applied. So for example when opening the view in portrait and then rotating to landscape, the insets left and right are still 0 and the content is rendered outside the safe area.
When looking at tableView.safeAreaInsets, you can see the values are not updated after rotating, and viewSafeAreaInsetsDidChange() does not get called. The bug can be reproduced with any transformation.
This worked perfectly fine in iOS 13. Is this a bug in UIKit? Is there a workaround?
So I just got a reply from Apple to a bug report I filed for this, and it turns out the propagation of safe area insets to a view with a scale or rotation transform is not supported. You have to apply the transform to a view deeper in the view hierarchy or handle it yourself some other way.
Bummer, but good to know.
Bummer, but good to know.