Skip to content

Commit

Permalink
Adjust view hierarchy after view transition
Browse files Browse the repository at this point in the history
Signed-off-by: Marcel Müller <marcel-mueller@gmx.de>
  • Loading branch information
SystemKeeper committed Apr 5, 2024
1 parent 2146749 commit 1408ecf
Showing 1 changed file with 19 additions and 0 deletions.
19 changes: 19 additions & 0 deletions NextcloudTalk/NCSplitViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,25 @@
}
}

override func viewWillTransition(to size: CGSize, with coordinator: any UIViewControllerTransitionCoordinator) {
super.viewWillTransition(to: size, with: coordinator)

coordinator.animate(alongsideTransition: nil) { _ in
guard self.isCollapsed else { return }

if let navController = self.viewController(for: .secondary) as? UINavigationController,
let chatViewController = self.getActiveChatViewController() {

// Make sure the navigationController has the correct reference to the chatViewController.
// After a transition (eg. portrait to landscape) the navigationController still references the
// the placeholderViewController in the navigationBar. When navigating back the app crashes in iOS 17,
// because the navigationBar is referenced twice.
navController.setViewControllers([self.placeholderViewController, chatViewController], animated: false)
navController.setViewControllers([chatViewController], animated: false)
}
}
}

func internalExecuteAfterTransition(action: @escaping () -> Void) {
if self.transitionCoordinator == nil {
// No ongoing animations -> execute action directly
Expand Down

0 comments on commit 1408ecf

Please sign in to comment.