Change UISegmentedControl from embedded UIPageVIewController using Swift

25 Views Asked by At

Ok so I'm a noob and am probably doing this all wrong but here goes...

I have a ViewController with a SegmentedControl. Originally, the SegmentedControl was simply switching between 3 UIViews. It worked fine, but I wanted that scrolling page swiping animated effect as well as the tab control of the SegmentedControl. So I decided to get rid of the 3 UIViews and add a ContainerView (below the SegmentedControl) with an embedded UIPageViewController with 3 UIViewControllers. Now, swiping through the pages of the PageViewController works and looks great.

Now, I want to not only change pages using the SegmentedControl, but I want to be able to change the index of the SegmentedControl when swiping through the pages. How do I reference something on the main ViewController from the embedded PageViewController?

By the way, the main ViewController, PageViewController, and child ViewControllers were all created in Storyboard, if that makes a difference.

0

There are 0 best solutions below