Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Fixed views not getting layouted on other animations then MoveAndScale

  • Loading branch information...
commit 110fb6a58d98442535f1f84dfc01ed4e8fbc3508 1 parent 10acd37
@myell0w myell0w authored
Showing with 17 additions and 4 deletions.
  1. +17 −4 NGVerticalTabBarController/NGVerticalTabBarController.m
View
21 NGVerticalTabBarController/NGVerticalTabBarController.m
@@ -21,7 +21,7 @@ @interface NGVerticalTabBarController () <UITableViewDataSource, UITableViewDele
unsigned int didSelectViewController:1;
} _delegateFlags;
- BOOL _transitionAnimationActive;
+ BOOL _moveScaleAnimationActive;
}
// re-defined as read/write
@@ -65,7 +65,7 @@ - (id)initWithDelegate:(id<NGVerticalTabBarControllerDelegate>)delegate {
_oldSelectedIndex = NSNotFound;
_animation = NGVerticalTabBarControllerAnimationNone;
_animationDuration = kNGDefaultAnimationDuration;
- _transitionAnimationActive = NO;
+ _moveScaleAnimationActive = NO;
// need to call setter here
self.delegate = delegate;
@@ -149,6 +149,18 @@ - (void)viewDidDisappear:(BOOL)animated {
}
}
+- (void)viewWillLayoutSubviews {
+ [super viewWillLayoutSubviews];
+
+ CGRect childViewControllerFrame = self.childViewControllerFrame;
+
+ if (!_moveScaleAnimationActive) {
+ for (UIViewController *viewController in self.viewControllers) {
+ viewController.view.frame = childViewControllerFrame;
+ }
+ }
+}
+
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation {
return [self.selectedViewController shouldAutorotateToInterfaceOrientation:toInterfaceOrientation];
}
@@ -343,6 +355,8 @@ - (void)updateUI {
newSelectedViewController.view.frame = frame;
if (self.animation == NGVerticalTabBarControllerAnimationMoveAndScale) {
+ _moveScaleAnimationActive = YES;
+
[UIView animateWithDuration:kNGScaleDuration
animations:^{
oldSelectedViewController.view.transform = CGAffineTransformMakeScale(kNGScaleFactor, kNGScaleFactor);
@@ -354,7 +368,6 @@ - (void)updateUI {
// if the user switches tabs too fast the viewControllers disappear from view hierarchy
// this is a workaround to not allow the user to switch during an animated transition
self.tabBar.userInteractionEnabled = NO;
- _transitionAnimationActive = YES;
[self transitionFromViewController:oldSelectedViewController
toViewController:newSelectedViewController
@@ -385,7 +398,7 @@ - (void)updateUI {
newSelectedViewController.view.transform = CGAffineTransformMakeScale(1.f, 1.f);
} completion:^(BOOL finished) {
newSelectedViewController.view.frame = self.childViewControllerFrame;
- _transitionAnimationActive = NO;
+ _moveScaleAnimationActive = NO;
}];
}
Please sign in to comment.
Something went wrong with that request. Please try again.