Skip to content

Commit

Permalink
Merge pull request #144 from Siroque/layoutFix
Browse files Browse the repository at this point in the history
The frame calculation of the OnboardingViewController subviews moved …
  • Loading branch information
mamaral authored Aug 9, 2016
2 parents ec80a71 + 580783b commit 0c00fe3
Showing 1 changed file with 9 additions and 5 deletions.
14 changes: 9 additions & 5 deletions Source/OnboardingViewController.m
Original file line number Diff line number Diff line change
Expand Up @@ -140,10 +140,17 @@ - (void)viewWillDisappear:(BOOL)animated {
}
}

- (void)viewWillLayoutSubviews {
[super viewWillLayoutSubviews];
self.pageVC.view.frame = self.view.frame;
self.moviePlayerController.view.frame = self.view.frame;
self.skipButton.frame = CGRectMake(CGRectGetMaxX(self.view.frame) - kSkipButtonWidth, CGRectGetMaxY(self.view.frame) - self.underPageControlPadding - kSkipButtonHeight, kSkipButtonWidth, kSkipButtonHeight);
self.pageControl.frame = CGRectMake(0, CGRectGetMaxY(self.view.frame) - self.underPageControlPadding - kPageControlHeight, self.view.frame.size.width, kPageControlHeight);
}

- (void)generateView {
// create our page view controller
self.pageVC = [[UIPageViewController alloc] initWithTransitionStyle:UIPageViewControllerTransitionStyleScroll navigationOrientation:UIPageViewControllerNavigationOrientationHorizontal options:nil];
self.pageVC.view.frame = self.view.frame;
self.pageVC.view.backgroundColor = [UIColor whiteColor];
self.pageVC.delegate = self;
self.pageVC.dataSource = self.swipingEnabled ? self : nil;
Expand Down Expand Up @@ -201,20 +208,17 @@ - (void)generateView {

self.moviePlayerController = [AVPlayerViewController new];
self.moviePlayerController.player = self.player;
self.moviePlayerController.view.frame = self.pageVC.view.frame;
self.moviePlayerController.showsPlaybackControls = NO;

[self.pageVC.view addSubview:self.moviePlayerController.view];
[self.pageVC.view sendSubviewToBack:self.moviePlayerController.view];
}

// create and configure the page control
self.pageControl.frame = CGRectMake(0, CGRectGetMaxY(self.view.frame) - self.underPageControlPadding - kPageControlHeight, self.view.frame.size.width, kPageControlHeight);
// create the page control
[self.view addSubview:self.pageControl];

// if we allow skipping, setup the skip button
if (self.allowSkipping) {
self.skipButton.frame = CGRectMake(CGRectGetMaxX(self.view.frame) - kSkipButtonWidth, CGRectGetMaxY(self.view.frame) - self.underPageControlPadding - kSkipButtonHeight, kSkipButtonWidth, kSkipButtonHeight);
[self.view addSubview:self.skipButton];
}

Expand Down

0 comments on commit 0c00fe3

Please sign in to comment.