From 3d62728a95fd25aa21ebc7661a0b7a394f64f466 Mon Sep 17 00:00:00 2001 From: Davide De Rosa Date: Sat, 27 Oct 2018 21:13:21 +0200 Subject: [PATCH] Fix detail replacement in compact mode Do not push created profile onto presented profile or any other screen deeper inside (e.g. Parameters). --- .../Scenes/Organizer/OrganizerViewController.swift | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/Passepartout-iOS/Scenes/Organizer/OrganizerViewController.swift b/Passepartout-iOS/Scenes/Organizer/OrganizerViewController.swift index 2dcfcd11..7a8723b2 100644 --- a/Passepartout-iOS/Scenes/Organizer/OrganizerViewController.swift +++ b/Passepartout-iOS/Scenes/Organizer/OrganizerViewController.swift @@ -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) } }