Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

UINavigationController pushViewController pauses/freezes midway through

I am pushing a view controller via:

[self.navigationController pushViewController:[[UIViewController alloc] init] animated:YES];

But the animation lags/pauses a for half a second mid way through. The animation is not complete. Here's the gif;

enter image description here

like image 530
0xSina Avatar asked Nov 11 '13 23:11

0xSina


1 Answers

With out more detail I can think of 2 possible problem with that.

  • Is there Shadow added in code to the view that will be covered by the new ViewController. If it is the case, use ShadowPath or an translucent view instead (the property Shadow is expensive while animating, been there done that)

  • Is the backgroundColor of new ViewController "clearColor" ? I've seen strange rendering problem with that kind of thing.

Try:

UIViewController *vc = [[UIViewController alloc] init];  
vc.view.backgroundColor = [UIColor whiteColor];  
[self.navigationController pushViewController:vc animated:YES];

That is the 2 possible problems I can think of the top of my head with so few detail.


Never rely on the default background color, it has change with iOS version and is not consistant across controls and can even be different if the view is created in code or from a Xib (in the same iOS version).

like image 68
Vincent Bernier Avatar answered Sep 21 '22 09:09

Vincent Bernier