Fix detail replacement in compact mode

Do not push created profile onto presented profile or any other
screen deeper inside (e.g. Parameters).
This commit is contained in:
Davide De Rosa 2018-10-27 21:13:21 +02:00
parent 06ecd3367f
commit 3d62728a95
1 changed files with 14 additions and 0 deletions

View File

@ -451,6 +451,20 @@ extension OrganizerViewController {
reloadModel()
tableView.reloadData()
// XXX: hack around bad replace when detail presented in compact view
if let detailNav = navigationController?.viewControllers.last as? UINavigationController {
var existingServiceVC: ServiceViewController?
for vc in detailNav.viewControllers {
if let found = vc as? ServiceViewController {
existingServiceVC = found
break
}
}
let serviceVC = existingServiceVC ?? (StoryboardScene.Main.serviceIdentifier.instantiate().topViewController as! ServiceViewController)
serviceVC.profile = profile
detailNav.setViewControllers([serviceVC], animated: true)
return
}
perform(segue: StoryboardSegue.Organizer.selectProfileSegueIdentifier, sender: profile)
}
}