• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
UIPageViewController not resizing its child view controllers on rotation
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

UIPageViewController not resizing its child view controllers on rotation


  • Subject: UIPageViewController not resizing its child view controllers on rotation
  • From: Devarshi Kulshreshtha <email@hidden>
  • Date: Tue, 30 Jun 2015 20:00:34 +0530

I am trying to use UIPageViewController with view controllers added to it,
problem is if I launch the app in portrait mode it appears perfectly like
this:

http://i.stack.imgur.com/ryT5d.png

but if I rotate the device to landscape mode it appears like this:

http://i.stack.imgur.com/GnuYH.png

Though pagination control has resized properly, view of added view
controller has not resized properly.

Below is the code which I have used to add respective view controller as
root view controller in AppDelegate:

    pagesContainerViewController = [[RWPagesContainerViewController alloc]
initWithNibName:@"RWPagesContainerViewController" bundle:nil];
    [pagesContainerViewController loadPaginationControlAtIndex:0];
    self.window.rootViewController = pagesContainerViewController;

Here is the implementation of loadPaginationControlAtIndex method:

    - (void)loadPaginationControlAtIndex:(RWPaginationView)viewIndex {
        _pageController = [[UIPageViewController alloc]
initWithTransitionStyle:UIPageViewControllerTransitionStyleScroll
navigationOrientation:UIPageViewControllerNavigationOrientationHorizontal
options:nil];

        FirstViewController *firstViewController = [[FirstViewController
alloc] initWithNibName:@"FirstViewController" bundle:nil];
        SecondViewController *secondViewController = [[SecondViewController
alloc] initWithNibName:@"SecondViewController" bundle:nil];
        ThirdViewController *thirdViewController = [[ThirdViewController
alloc] initWithNibName:@"ThirdViewController" bundle:nil];

        _subviewControllers = @[firstViewController, secondViewController,
thirdViewController];

        [self.pageController
setViewControllers:@[_subviewControllers[viewIndex]]
direction:UIPageViewControllerNavigationDirectionForward animated:YES
completion:nil];

        [self addChildViewController:self.pageController];
        [[self view] addSubview:[self.pageController view]];

        UIView *insertedView = self.pageController.view;
        insertedView.translatesAutoresizingMaskIntoConstraints = NO;
        self.view.translatesAutoresizingMaskIntoConstraints = NO;

        [self.view addConstraints:[NSLayoutConstraint
constraintsWithVisualFormat:@"H:|[insertedView]|"

options:0

metrics:nil

views:NSDictionaryOfVariableBindings(insertedView)]];
        [self.view addConstraints:[NSLayoutConstraint
constraintsWithVisualFormat:@"V:|[insertedView]|"

options:0

metrics:nil

views:NSDictionaryOfVariableBindings(insertedView)]];

        [self.view layoutIfNeeded];

        self.pageController.dataSource = self;
    }

Am I missing anything? Please suggest.

--
Thanks,

Devarshi
_______________________________________________

Cocoa-dev mailing list (email@hidden)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:

This email sent to email@hidden


  • Follow-Ups:
    • Re: UIPageViewController not resizing its child view controllers on rotation
      • From: Ben Kennedy <email@hidden>
  • Prev by Date: Window Update Problem
  • Next by Date: Re: Cheating a synchronous call on the main thread
  • Previous by thread: Re: Window Update Problem
  • Next by thread: Re: UIPageViewController not resizing its child view controllers on rotation
  • Index(es):
    • Date
    • Thread