Slow performance of the current ViewController

I use UIViewControllerTransitioningDelegate to create custom transitions between two view controllers (from MKMapView ) to a custom camera built-in ( AVFoundation ). Everything goes well until I call presentViewController , and it seems that the phone lasts about 1 second (when I go out). This even happens when I switch to a much simpler view (I have a view controller that only displays a UITextview and even with what appears to be about a delay of 0.4 - 0.5 seconds before the transition actually called out).

I am currently calling the transition

  dispatch_async(dispatch_get_main_queue(), ^{ UIStoryboard* sb = [UIStoryboard storyboardWithName:@"Main" bundle:nil]; CameraViewController *cvc2 = [sb instantiateViewControllerWithIdentifier:@"Camera"]; cvc2.modalPresentationStyle = UIModalPresentationFullScreen; // Needed for custom animations to work cvc2.transitioningDelegate = self; //Conforms to the UIViewControllerTransitioningDelegate protocol [self presentViewController:cvc2 animated:YES completion:nil]; }); 

Here is my animateTransition method for this call. Very straight forward, and currently the view that represents it has only MKMapView (no additional views or methods).

 -(void)animateTransition:(id<UIViewControllerContextTransitioning>)transitionContext { if (self.type == MapAnimationTypePresent) {//From map to another view UIView *containerView = [transitionContext containerView]; UIViewController *fromViewController = [transitionContext viewControllerForKey:UITransitionContextFromViewControllerKey]; UIViewController *toViewController = [transitionContext viewControllerForKey:UITransitionContextToViewControllerKey]; // Amazing category for iOS 7 compatibility found here - http://stackoverflow.com/a/25193675/2939977 UIView *toView = [toViewController viewForTransitionContext:transitionContext]; UIView *fromView = [fromViewController viewForTransitionContext:transitionContext]; toView.frame = self.view.frame; fromView.frame = self.view.frame; //Add 'to' view to the hierarchy toView.alpha = 0; [containerView insertSubview:toView aboveSubview:fromView]; [UIView animateWithDuration:.5 animations:^{ toView.alpha = 1; }completion:^(BOOL finished) { [transitionContext completeTransition:YES]; }]; } 

Any help is greatly appreciated.

+5
source share

Source: https://habr.com/ru/post/1205140/


All Articles