remove destination view controller when transition canceled

This commit is contained in:
Michael Chen 2018-06-05 09:41:10 -04:00
parent 92fb1d96b8
commit d3b078e984

View File

@ -106,10 +106,7 @@
// Replaces the current view controller.
NSMutableArray *viewControllers = [NSMutableArray arrayWithArray:self.navigationObject.navigationController.viewControllers];
if (viewControllers.count > 1) {
[viewControllers removeObjectAtIndex:0];
}
[viewControllers replaceObjectAtIndex:(viewControllers.count - 1) withObject:self.navigationObject.viewController];
[viewControllers replaceObjectAtIndex:([self.navigationObject.navigationController.viewControllers count] - 1) withObject:self.navigationObject.viewController];
[self setViewControllers:viewControllers];
} else {
@ -262,8 +259,10 @@
- (void)observeValueForKeyPath:(NSString *)keyPath ofObject:(id)object change:(NSDictionary<NSKeyValueChangeKey,id> *)change context:(void *)context {
if ([keyPath isEqualToString:@"interactiveTransitionCanceled"]) {
BOOL transitionStoped = ((NSNumber*)change[NSKeyValueChangeNewKey]).boolValue;
if (transitionStoped) {
BOOL transitionCanceled = ((NSNumber*)change[NSKeyValueChangeNewKey]).boolValue;
if (transitionCanceled) {
//When interactive transition canceled, the destination viewController should be removed from navigationController
[self.navigationObject.viewController removeFromParentViewController];
[self markAsFinished];
}
}