UIActivityIndicatorView freeze when using custom segue
-
15-11-2019 - |
Question
i need help here, i'm using a custom segue to push a view controller to another view controller.
when pushed using cutom segue, the uiactivityindicator will not animate automatically when view loaded.
however if i used the push method on the storyboard, the uiactivityindicator animate automatically.
what i had done wrong ?
-(void)perform {
UIViewController *sourceVC = (UIViewController *) self.sourceViewController;
UIViewController *destinationVC = (UIViewController *) self.destinationViewController;
[UIView transitionWithView:sourceVC.navigationController.view duration:0.5
options:UIViewAnimationOptionTransitionCrossDissolve
animations:^{
[sourceVC.navigationController pushViewController:destinationVC animated:NO];
//NSLog(@"count of subview %i", [self.view.subviews count]);
}
completion:NULL];
}
Solution
Try this:
UIViewController *sourceVC = (UIViewController *) self.sourceViewController;
UIViewController *destinationVC = (UIViewController *) self.destinationViewController;
[UIView transitionFromView:sourceVC.view toView:destinationVC.view duration:.5 options:0 completion:^(BOOL finished) {
[sourceVC.navigationController pushViewController:destinationVC animated:NO];
}];
The -pushViewController:animated:
should not be putted in the animation block but the completion block.
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow