简体   繁体   中英

UITabBarController, animation causes sliding of other views without a UINavigationController

I've run into an animation issue (I think) with my TabBar based app. I have four tab bar items, of those three have UINavigationControllers, and one of them just has a regular view controller. The issue is that after changing to a view with animations, the first tab without a UINavigationController seems to no longer have the right size/position when changing bars.

Initially you're able to step through all four tabs without issue, but after the animated view has been used, the first view will appear with a sliding down animation, as if it was positioned incorrectly. Conversely, the other views will "slide up" about 20px when activated. I've got the first view not autosized in the IB, and it has the same height as the other views. I've also tried padding its height by 44px (the height of a NavigationBar) but it showed the same effect.

Also, once this bug is in effect, if another view is activated for the first time; it appears in a weird animated fashion, with its individual elements growing from the bottom left and moving into place.

Any advice is appreciated, I'm inclined to believe it's related to the height or size of that view without a nav controller; or that the animation on my one view isn't being canceled correctly. That view has the following trying to prevent it (but it didn't work):

-(void)viewWillDisappear:(BOOL)animated {  
  [UIView beginAnimations:nil context:NULL];  
  [UIView setAnimationBeginsFromCurrentState:YES];  
  [UIView setAnimationDuration:0.1];  
  [UIView setAnimationCurve: UIViewAnimationCurveLinear];  
  [UIView commitAnimations];  

  [super viewWillDisappear:false];  
}

The problem had nothing to do with the different views. I had opened an animation block, and not closed it. This won't be caught as a syntax error, but will produce a never ending animation on every transition. If you're seeing the sliding views, I recommend reviewing any place with animation, and confirming the block is closed.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM