diff --git a/MVMCore/MVMCore/PresentationHandling/MVMCoreNavigationOperation.m b/MVMCore/MVMCore/PresentationHandling/MVMCoreNavigationOperation.m index ffd3c82..95f78cd 100644 --- a/MVMCore/MVMCore/PresentationHandling/MVMCoreNavigationOperation.m +++ b/MVMCore/MVMCore/PresentationHandling/MVMCoreNavigationOperation.m @@ -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 *)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]; } }