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:
Run the app. Notice that there is not a 100 point margin below the label
In Main.storyboard, change the embedded view to point to the green UIViewController instead.
Run the app. Notice that the 100 point margin is now there.
In Main.storyboard, change the embedded view back to the pink UICollectionViewController
In ViewController.swift, uncomment the line that says view.layoutIfNeeded()
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.
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'sviewDidLoad
method.Steps to Reproduce: In the sample app:
view.layoutIfNeeded()
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