I currently have an application with a UI Similar to the Snapchat ScrollView. The MainViewController contains a UIScroll, in which three child ViewControllers are added as child ViewControllers:
override func viewDidLoad() {
super.viewDidLoad()
scrollView.contentSize = CGSizeMake((self.view.bounds.width*3 + 4), self.view.bounds.height)
self.view.addSubview(scrollView)
let view1 = UIView(frame: CGRectMake(0, 0, self.view.bounds.width, self.view.bounds.height))
scrollView.addSubview(view1)
let aVC = self.storyboard?.instantiateViewControllerWithIdentifier("One")
view1.addSubview(aVC!.view)
self.addChildViewController(aVC!)
let view2 = UIView(frame: CGRectMake((self.view.bounds.width), 0, self.view.bounds.width, self.view.bounds.height))
scrollView.addSubview(view2)
let bVC = self.storyboard?.instantiateViewControllerWithIdentifier("Two")
view2.addSubview(bVC!.view)
self.addChildViewController(bVC!)
let view3 = UIView(frame: CGRectMake(2*view.bounds.width), 0, self.view.bounds.width, self.view.bounds.height))
scrollView.addSubview(view3)
let cVC = self.storyboard?.instantiateViewControllerWithIdentifier("LocationViewController")
view3.addSubview(cVC!.view)
self.addChildViewController(cVC!)
scrollView.contentOffset = CGPointMake(self.view.frame.width, 0
}
I attempting to add buttons two the middle ViewController, which will offset the ScrollView to either the left or right View Controllers. I know I can use setContentOffset() in the MainViewController, but I cannot call this in the child view controllers. Both self.presentingViewController and self.parentViewController both return nil.
What is the best way to call setContentOffset() for the UIScrollView, within a child ViewController?