HeroTransitions / HeroTransitions/Hero
UIViewController deallocated when using function replaceViewController(with:completion)
- Dominant language
- Swift
- Stars
- 22.5k
- Forks
- 1.7k
- PR merge metrics
- No merged PRs in 30d
Description
## 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
* Hero Version: 1.6.0
* iOS Version(s): All
* Swift Version: All
* Devices/Simulators: All
* Reproducible in Examples? (Yes/No):
Reproducible in any project when you want to replace root view in any `UIWindow`
Contributor guide
No contributing guide indexed for this repository
Assessment
This issue has not been assessed yet.