Hello to all! I added the UICollectionView as a SubView to another controller, set the frame in this parent controller for the UICollectionView view, made a Scroll horizontally. I want to have only one row of items displayed on me and I could scroll horizontally, but I have 2 rows displayed (in fact, if I move up Y, then several more rows will be displayed). I tried several different methods, but they did not help me. I also tried to do it in IB using UIContainerController , it works, but I need to do it in code. How can I fix this?
My code that adds a UICollectionView
override func viewDidLoad() { super.viewDidLoad() addUIElements() } // MARK: - UI functions private func addUIElements() { view.addSubview(headerView) let lifelineController = StoryboardManager.lifeLineStoryboard.instantiateViewControllerWithIdentifier("LifeLineCollectionViewController") as! LifeLineCollectionViewController addChildViewController(lifelineController) lifelineController.view.frame = CGRect(x: 0, y: headerView.frame.height, width: headerView.frame.width, height: 100) view.addSubview(lifelineController.view) lifelineController.didMoveToParentViewController(self) } 