HeroTransitions / Hero

Elegant transition library for iOS & tvOS
https://HeroTransitions.github.io/Hero/
MIT License
22k stars 1.72k forks source link

UIViewController deallocated when using function replaceViewController(with:completion) #717

Open rafalwojcik opened 3 years ago

rafalwojcik commented 3 years ago

What did you do?

I'm trying to replace the view controller on the main window of the application, but in commit https://github.com/HeroTransitions/Hero/commit/800b9d90238e385df8bb69f5e94887e2d0e7a695 you've introduced a regression. by removing ! from #if !TARGET_IS_EXTENSION. Probably it is also causing issues in extensions that do not have UIApplication class. Actually, that code was removed in favor of code from PR #705:

if let parentVC = parentVC {
  base.dismiss(animated: false) {
    parentVC.present(next, animated: false, completion: completion)
  }
} else {
  parentVC?.view.window?.rootViewController = next
}

which doesn't have any sense because in else statement parentVC will be always nil.

What did you expect to happen?

It should just replace the root view controller on that window without deallocating view controller.

What happened instead?

View in the hierarchy is replaced but View Controller is deallocated.

General Information