Fixed iOS 8 bug with rejectViewControllerAnimated function: completion: animation?

IOS documentation for dismissViewControllerAnimated:completion: ::

If you consecutively represent several view controllers, the stack of view controllers represented by calling this method in the view of the controller below in the stack rejects its immediate view as the child controller and all view controllers above this child in the stack. When this happens, only the topmost view is rejected in the animated mode; any intermediate controllers are simply removed from the stack. The topmost view is rejected using its modal style transition, which may differ from the styles used by other view controllers below in the stack.

This means that while disabling the two modal view dispatchers with

[[[self presentingViewController] presentingViewController] dismissViewControllerAnimated:YES completion:nil];

the animation shown should be overridden by a higher modal view.

This is true in iOS 7 and earlier, but in iOS 8 the animation shown is not the best point of view (in my experience, this is the second top view). Is this behavior a bug in iOS 8 or am I doing something wrong?

+6
source share
2 answers

As noted above: I see the same problem in the context of segue unwinding. I just get around the workaround as described here, using the screenshot and add it as a subtitle for all intermediate viewControllers: How to remove a stack of modal view controllers with animation without blinking on the screen of any of the presented VCs between the top and bottom?

  // this in during unwind in a custom UIStoryboardSegue (that is the reason why it might look wrong with what is what: srcViewController and destViewController UIViewController* aPresentedViewController = destViewController.presentedViewController; while (aPresentedViewController != nil) { if (aPresentedViewController == srcViewController) { break; } UIView *anotherSrcViewCopy = [srcViewController.view snapshotViewAfterScreenUpdates: NO]; anotherSrcViewCopy.autoresizingMask = UIViewAutoresizingFlexibleHeight | UIViewAutoresizingFlexibleWidth; [aPresentedViewController.view addSubview:anotherSrcViewCopy]; // recurse through the presentedViewController hierarchy aPresentedViewController = aPresentedViewController.presentedViewController; } 
+3
source

Same problem and same solution here than @theguy. Here is my version in Swift without repeating on all view controllers:

 guard let presentedViewController = segue.destination.presentedViewController, let viewToCopy = segue.source.view.snapshotView(afterScreenUpdates: false) else { return } viewToCopy.autoresizingMask = [.flexibleWidth, .flexibleHeight] presentedViewController.view.addSubview(viewToCopy) 
+1
source

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


All Articles