Adding other view controllers, since the children simply bind the view controllers - they do not add the views they control as subviews. Thus, when you add them as children, you must also add sub-items and set the initial frames. You may also need to add gesture wipes to trigger a view animation to animate view frames (although there are several other options, such as scrolling).
As part of the animation for moving views, you manually refresh the page control (this will not happen automatically).
The loadScrollViewWithPage
method is the key. Call this parameter 0
and then 1
to load both pages and add subzones views. Just change self.scrollView
to self.view
.
I would add (two actually, but first started working) to move on to managing the page. Then, when it is displayed, you can move other views.
Gesture motion callback:
- (void)swipeRightToLeftGesture:(UIGestureRecognizer *)gestureRecognizer { [UIView animateWithDuration:1 animations:^{ for (UIViewController *vc in self.childViewControllers) { CGRect frame = vc.view.frame; frame.origin.x -= self.view.frame.size.width; vc.view.frame = frame; } }]; }
These iterate over the child view controllers and animate their view frames to move them to the left. Scrolling left to the right handler will be the same, except that the width +=
will shift to the right.
[Code Edited - Syntax]
source share