iOS App Freezes on Pushviewcontroller

iOS App Freezes on PushViewController

We have faced the same problem couple of weeks back. And for our problem we narrowed it down to left-edge pop gesture recogniser. You can try and check if you can reproduce this problem using below steps

  • Try using the left edge pop gesture when there are no view controllers below it (i.e on root view controllers, your VC-Home controller)
  • Try clicking on any UI elements after this.

If you are able to reproduce the freeze, try disabling the interactivePopGestureRecognizer when the view controller stack have only one view controller.

Refer to this question for more details. Below is the code from the link for ease of reference.

- (void)navigationController:(UINavigationController *)navigationController
didShowViewController:(UIViewController *)viewController
animated:(BOOL)animate
{
if ([self respondsToSelector:@selector(interactivePopGestureRecognizer)])
{
if (self.viewControllers.count > 1)
{
self.interactivePopGestureRecognizer.enabled = YES;
}
else
{
self.interactivePopGestureRecognizer.enabled = NO;
}
}
}

iOS - App freezes when push from navigation controller

I managed to find a solution here

So my interactivePopGestureRecognizer is enabled even when the current visible view controller is the only VC on the navigation stack. Simply disable that will solve the bug.

UINavigationController pushViewController pauses/freezes midway through

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).



Related Topics



Leave a reply



Submit