Simple scenario, but the problem is driving me crazy..
What I want to achieve: UITableViewCell's contentView to be aligned with separatorInset in each and every scenario.
Result: The layoutMargin.left is different from separatorInset when shown in a Popover as page sheet (i.e. iPhone 6/6S Plus) with iOS 8.1-8.2 and iOS 9.x. iOS 8.3 and 8.4 work fine.
Cell Settings:
- preservesSuperviewLayoutMargins and contentView.preservesSuperviewLayoutMargins are true
- autoLayout of Label is pinned to superView margins with constant 0
Investigations: If found this post from matt, explaining the underlying problem a bit: https://stackoverflow.com/a/29712427/844907
I implemented a layoutDidChange method to check the margins:
override func layoutMarginsDidChange() {
debugPrint("layoutMarginsDidChange: ", layoutMargins.left, contentView.layoutMargins.left, separatorInset.left)
}
Some of the returned values after a few rotations from PageSheet to FullScreen:
"layoutMarginsDidChange: " 16.0 16.0 20.0 ("real" popOver on 6+ with 8.2) "layoutMarginsDidChange: " 20.0 20.0 20.0 (FullScreen 6+ with 8.2)
Or on iPhone 6+ 9.3:
FullScreen (both lines!):
"layoutMarginsDidChange: " 8.0 8.0 20.0
"layoutMarginsDidChange: " 20.0 20.0 20.0
After rotation to pageSheet:
"layoutMarginsDidChange: " 16.0 16.0 20.0
Last value is the separator.left, first two are the layoutMargins.left and contentView.layoutMargins.left.
Any idea how to fix this?
I though of setting layoutMargins.left to separatorInset.left but this doesn't felt right without knowing the source of the problem..
See images below: