Skip to content

Commit

Permalink
Merge pull request #1612 from nextcloud/fix-view-hierachy-after-trans…
Browse files Browse the repository at this point in the history
…ition

Adjust view hierarchy after view transition
  • Loading branch information
Ivansss authored Apr 5, 2024
2 parents 5304339 + 1408ecf commit 6305c09
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 6305c09

Please sign in to comment.