lionheart / openradar-mirror

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

26355756: Layout margin on UIStackView not respected when UICollectionView is present #14713

Open openradar-mirror opened 8 years ago

openradar-mirror commented 8 years ago

Description

Summary: I create a vertical stack view containing a label followed by a container view that embeds a UICollectionViewController. I then embed the label inside another stack view, set its layout margins to explicit and give it a 100 point bottom margin.

When I run the app, the bottom margin is not 100. Instead, it is something like 16 points. If I embed a UIViewController instead of a UICollectionViewController then it works as expected.

I can workaround this issue by calling view.layoutIfNeeded() in the main view controller's viewDidLoad method.

Steps to Reproduce: In the sample app:

  1. Run the app. Notice that there is not a 100 point margin below the label
  2. In Main.storyboard, change the embedded view to point to the green UIViewController instead.
  3. Run the app. Notice that the 100 point margin is now there.
  4. In Main.storyboard, change the embedded view back to the pink UICollectionViewController
  5. In ViewController.swift, uncomment the line that says view.layoutIfNeeded()
  6. Run the app. Notice that the 100 point margin is now there.

Expected Results: The layout margin of the UIStackView would be respected when I use an container view that contains a UICollectionViewController.

Actual Results: The layout margin is a value other than what I set.

iPhone 6 Plus, 64GB AT&T

Version: iOS 9.3.2

Notes:

Configuration: iPhone 6 Plus, 64GB AT&T

Sample project: https://dl.dropboxusercontent.com/u/8211174/NestedStackViews.zip

Product Version: 9.3.2 Created: 2016-05-18T22:35:48.655780 Originated: 2016-05-18T16:32:00 Open Radar Link: http://www.openradar.me/26355756

openradar-mirror commented 8 years ago

Modified: 2016-05-18T22:44:19.616000