Skip to content
This repository
Browse code

Fixed views not getting layouted on other animations then MoveAndScale

  • Loading branch information...
commit 110fb6a58d98442535f1f84dfc01ed4e8fbc3508 1 parent 10acd37
Matthias Tretter myell0w authored

Showing 1 changed file with 17 additions and 4 deletions. Show diff stats Hide diff stats

  1. +17 4 NGVerticalTabBarController/NGVerticalTabBarController.m
21 NGVerticalTabBarController/NGVerticalTabBarController.m
@@ -21,7 +21,7 @@ @interface NGVerticalTabBarController () <UITableViewDataSource, UITableViewDele
21 21 unsigned int didSelectViewController:1;
22 22 } _delegateFlags;
23 23
24   - BOOL _transitionAnimationActive;
  24 + BOOL _moveScaleAnimationActive;
25 25 }
26 26
27 27 // re-defined as read/write
@@ -65,7 +65,7 @@ - (id)initWithDelegate:(id<NGVerticalTabBarControllerDelegate>)delegate {
65 65 _oldSelectedIndex = NSNotFound;
66 66 _animation = NGVerticalTabBarControllerAnimationNone;
67 67 _animationDuration = kNGDefaultAnimationDuration;
68   - _transitionAnimationActive = NO;
  68 + _moveScaleAnimationActive = NO;
69 69
70 70 // need to call setter here
71 71 self.delegate = delegate;
@@ -149,6 +149,18 @@ - (void)viewDidDisappear:(BOOL)animated {
149 149 }
150 150 }
151 151
  152 +- (void)viewWillLayoutSubviews {
  153 + [super viewWillLayoutSubviews];
  154 +
  155 + CGRect childViewControllerFrame = self.childViewControllerFrame;
  156 +
  157 + if (!_moveScaleAnimationActive) {
  158 + for (UIViewController *viewController in self.viewControllers) {
  159 + viewController.view.frame = childViewControllerFrame;
  160 + }
  161 + }
  162 +}
  163 +
152 164 - (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation {
153 165 return [self.selectedViewController shouldAutorotateToInterfaceOrientation:toInterfaceOrientation];
154 166 }
@@ -343,6 +355,8 @@ - (void)updateUI {
343 355 newSelectedViewController.view.frame = frame;
344 356
345 357 if (self.animation == NGVerticalTabBarControllerAnimationMoveAndScale) {
  358 + _moveScaleAnimationActive = YES;
  359 +
346 360 [UIView animateWithDuration:kNGScaleDuration
347 361 animations:^{
348 362 oldSelectedViewController.view.transform = CGAffineTransformMakeScale(kNGScaleFactor, kNGScaleFactor);
@@ -354,7 +368,6 @@ - (void)updateUI {
354 368 // if the user switches tabs too fast the viewControllers disappear from view hierarchy
355 369 // this is a workaround to not allow the user to switch during an animated transition
356 370 self.tabBar.userInteractionEnabled = NO;
357   - _transitionAnimationActive = YES;
358 371
359 372 [self transitionFromViewController:oldSelectedViewController
360 373 toViewController:newSelectedViewController
@@ -385,7 +398,7 @@ - (void)updateUI {
385 398 newSelectedViewController.view.transform = CGAffineTransformMakeScale(1.f, 1.f);
386 399 } completion:^(BOOL finished) {
387 400 newSelectedViewController.view.frame = self.childViewControllerFrame;
388   - _transitionAnimationActive = NO;
  401 + _moveScaleAnimationActive = NO;
389 402 }];
390 403 }
391 404

0 comments on commit 110fb6a

Please sign in to comment.
Something went wrong with that request. Please try again.