Layout margin on UIStackView not respected when UICollectionView is present
| Originator: | ben.dolman | ||
| Number: | rdar://26355756 | Date Originated: | 18-May-2016 04:32 PM |
| Status: | Open | Resolved: | |
| Product: | iOS SDK | Product Version: | 9.3.2 |
| Classification: | Reproducible: | Always |
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
Comments
Please note: Reports posted here will not necessarily be seen by Apple. All problems should be submitted at bugreport.apple.com before they are posted here. Please only post information for Radars that you have filed yourself, and please do not include Apple confidential information in your posts. Thank you!