I have a Storyboard setup with a UIViewController with an container view so that I can embed another UIViewController inside of it.
In a ce
Swift version with UIPageViewController (which I believe is a common use case for this)
let pageController = UIPageViewController(transitionStyle: .scroll, navigationOrientation: .horizontal, options: nil)
// do your PageViewController stuff here (delegate and dataSource)
pageController.willMove(toParent: self)
containerView.addSubview(pageController.view)
pageController.view.translatesAutoresizingMaskIntoConstraints = false
NSLayoutConstraint.activate([
pageController.view.topAnchor.constraint(equalTo: containerView.topAnchor),
pageController.view.bottomAnchor.constraint(equalTo: containerView.bottomAnchor),
pageController.view.leadingAnchor.constraint(equalTo: containerView.leadingAnchor),
pageController.view.trailingAnchor.constraint(equalTo: containerView.trailingAnchor)
])
addChild(pageController)
pageController.didMove(toParent: self)
I didn't figure out how to make use of the UIPageControll included in UIPageViewController so I ended up using my own instance. But I believe this is out of the scope of this question.