lionheart / openradar-mirror

A mirror of radars pulled from http://openradar.me/.
245 stars 17 forks source link

41363057: `UITableView -layoutMargins` returns wrong values in `tableView(_ :heightForRowAt:)` during rotation #19967

Open openradar-mirror opened 6 years ago

openradar-mirror commented 6 years ago

Description

Summary: UITableView -layoutMargins returns wrong values in tableView(_ :heightForRowAt:) and tableView(_: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 added UITableView control to view (attach top, left, bottom, right edges to superview) with enabled preservesSuperviewLayoutMargins property (in IB via Preserve Superview Margins option). Displays one cell and prints view.layoutMargins, tableView.layoutMargins properties in tableView(_: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 in tableView(_:heightForRowAt:) and tableView(_:estimatedHeightForRowAt:) methods during rotation.

Actual Results: UITableView -layoutMargins property returns .left or .right value from previous orientation in tableView(_:heightForRowAt:) and tableView(_: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

openradar-mirror commented 6 years ago

Modified: 2018-08-05T16:08:25.045040

openradar-mirror commented 6 years ago

Modified: 2018-08-05T16:08:25.045040

openradar-mirror commented 6 years ago

Modified: 2018-08-05T16:08:25.045040

openradar-mirror commented 6 years ago

Modified: 2018-08-05T16:08:25.045040

openradar-mirror commented 6 years ago

Modified: 2018-08-05T16:08:25.045040

openradar-mirror commented 6 years ago

Modified: 2018-08-05T16:08:25.045040

openradar-mirror commented 6 years ago

Modified: 2018-08-05T16:08:25.045040

openradar-mirror commented 6 years ago

Modified: 2018-08-05T16:08:25.045040

openradar-mirror commented 6 years ago

Modified: 2018-08-05T16:08:25.045040

openradar-mirror commented 6 years ago

Modified: 2018-08-05T16:08:25.045040

openradar-mirror commented 6 years ago

Modified: 2018-08-05T16:08:25.045040

openradar-mirror commented 6 years ago

Modified: 2018-08-05T16:08:25.045040

openradar-mirror commented 6 years ago

Modified: 2018-08-05T16:08:25.045040

openradar-mirror commented 6 years ago

Modified: 2018-08-05T16:08:25.045040

openradar-mirror commented 6 years ago

Modified: 2018-08-05T16:08:25.045040

openradar-mirror commented 6 years ago

Modified: 2018-08-05T16:08:25.045040