Last Updated: February 25, 2016
· widescape

Storyboard/UIPageViewController resets subviews' positions

Do you have a SinglePageViewController in a UIPageViewController and programmatically adjust positions of subviews defined in your Storyboard? Then you'll probably see jumping subviews on your pages whenever you start to swipe from one page to another. Why? Because UIPageViewController will layout the subviews of the SinglePageViewControllers whenever a swipe starts.

You have 2 options:

1) Turn off "Use Auto Layout" in your StoryBoard's file inspector panel.

2) Adjust the subviews' positions programmatically in viewDidLayoutSubviews.

// SinglePageViewController.m
-(void)viewDidLayoutSubviews {
  // Adjust the subviews' positions

There you go. No more jumping subviews. :)

2 Responses
Add your response

does any other way to solve this problem?

over 1 year ago ·

I guess, instead you could leave Auto Layout turned on, define proper Layout Constraints, assign them to IBOutlets in your view/controller and adjust them programmatically whenever needed. I didn't know how to do that half a year ago.

over 1 year ago ·