Open openradar-mirror opened 6 years ago
Modified: 2018-08-05T16:08:25.045040
Modified: 2018-08-05T16:08:25.045040
Modified: 2018-08-05T16:08:25.045040
Modified: 2018-08-05T16:08:25.045040
Modified: 2018-08-05T16:08:25.045040
Modified: 2018-08-05T16:08:25.045040
Modified: 2018-08-05T16:08:25.045040
Modified: 2018-08-05T16:08:25.045040
Modified: 2018-08-05T16:08:25.045040
Modified: 2018-08-05T16:08:25.045040
Modified: 2018-08-05T16:08:25.045040
Modified: 2018-08-05T16:08:25.045040
Modified: 2018-08-05T16:08:25.045040
Modified: 2018-08-05T16:08:25.045040
Modified: 2018-08-05T16:08:25.045040
Modified: 2018-08-05T16:08:25.045040
Description
Summary:
UITableView -layoutMargins
returns wrong values intableView(_ :heightForRowAt:)
andtableView(_:estimatedHeightForRowAt:)
methods during rotation. It's serious because it's causing problems when computing cell height depends of available width (eg. tableView.bounds.width - tableView.layoutMargins.left - tableView.layoutMargins.right).Steps to Reproduce: Open attached project: https://github.com/Grubas7/LayoutMarginsRotationBug (Projects contains application with
UIViewController
instance and addedUITableView
control to view (attach top, left, bottom, right edges to superview) with enabledpreservesSuperviewLayoutMargins
property (in IB viaPreserve Superview Margins
option). Displays one cell and printsview.layoutMargins
,tableView.layoutMargins
properties intableView(_:heightForRowAt:)
method) Run project on iPhone X in portrait orientation: Console will print proper margins for portrait orientation UIViewController's root view layout margins UIEdgeInsets(top: 44.0, left: 16.0, bottom: 34.0, right: 16.0) UITableView layout margins UIEdgeInsets(top: 52.0, left: 16.0, bottom: 42.0, right: 16.0)Run project on iPhone X in landscape orientation: Console will print proper margins for landscape orientation UIViewController's root view layout margins UIEdgeInsets(top: 0.0, left: 64.0, bottom: 21.0, right: 64.0) UITableView layout margins UIEdgeInsets(top: 8.0, left: 64.0, bottom: 29.0, right: 64.0)
Run project on iPhone X in landscape orientation and rotate to portrait: Console will print margins with wrong
tableView.layoutMargins.left
value (15.0 instead of 16.0) UIViewController's root view layout margins UIEdgeInsets(top: 44.0, left: 16.0, bottom: 34.0, right: 16.0) UITableView layout margins UIEdgeInsets(top: 52.0, left: 15.0, bottom: 8.0, right: 16.0)Run project on iPhone X in portrait orientation and rotate to landscape: Console will print margins with wrong
tableView.layoutMargins.right
value (15.0 instead of 64.0) UIViewController's root view layout margins UIEdgeInsets(top: 0.0, left: 64.0, bottom: 21.0, right: 64.0) UITableView layout margins UIEdgeInsets(top: 8.0, left: 64.0, bottom: 29.0, right: 15.0)Expected Results:
UITableView -layoutMargins
property should return equal.left
and.right
values intableView(_:heightForRowAt:)
andtableView(_:estimatedHeightForRowAt:)
methods during rotation.Actual Results:
UITableView -layoutMargins
property returns.left
or.right
value from previous orientation intableView(_:heightForRowAt:)
andtableView(_:estimatedHeightForRowAt:)
methods during rotation.Version/Build: iPhone X device and simulator, iOS 11.0 and later.
Configuration: Device rotation is unlocked.
- Product Version: 11.0 Created: 2018-06-22T10:41:46.397581 Originated: 2018-06-22T00:00:00 Open Radar Link: http://www.openradar.me/41363057