diff --git a/packages/playground/ios/SparklingGoTests/Application/SPKRouterTests.swift b/packages/playground/ios/SparklingGoTests/Application/SPKRouterTests.swift index 5777209e..8d6ad6e6 100644 --- a/packages/playground/ios/SparklingGoTests/Application/SPKRouterTests.swift +++ b/packages/playground/ios/SparklingGoTests/Application/SPKRouterTests.swift @@ -115,6 +115,33 @@ struct SPKRouterTests { } } + @Test func navigationControllerUsesNonSparklingTopControllerPolicy() { + final class HostViewController: UIViewController { + override var supportedInterfaceOrientations: UIInterfaceOrientationMask { + .portraitUpsideDown + } + + override var preferredInterfaceOrientationForPresentation: UIInterfaceOrientation { + .portraitUpsideDown + } + } + + let delegate = SPKViewController( + withURL: nil, + config: SPKSchemeParam(), + context: SPKContext(), + frame: .zero) + let host = HostViewController() + let navigationController = UINavigationController(rootViewController: host) + + #expect( + delegate.navigationControllerSupportedInterfaceOrientations( + navigationController) == .portraitUpsideDown) + #expect( + delegate.navigationControllerPreferredInterfaceOrientationForPresentation( + navigationController) == .portraitUpsideDown) + } + @Test func viewAppearanceSchedulesPortraitGeometryUpdate() { let context = SPKContext() context.interfaceOrientationPolicy = .portrait diff --git a/packages/sparkling-sdk/ios/Sparkling/Sources/Application/Container/SPKViewController.swift b/packages/sparkling-sdk/ios/Sparkling/Sources/Application/Container/SPKViewController.swift index 1e968f2f..deacfd0b 100644 --- a/packages/sparkling-sdk/ios/Sparkling/Sources/Application/Container/SPKViewController.swift +++ b/packages/sparkling-sdk/ios/Sparkling/Sources/Application/Container/SPKViewController.swift @@ -1121,16 +1121,16 @@ extension SPKViewController: UINavigationControllerDelegate { public func navigationControllerSupportedInterfaceOrientations( _ navigationController: UINavigationController ) -> UIInterfaceOrientationMask { - return (navigationController.topViewController as? SPKViewController)? - .supportedInterfaceOrientations ?? navigationController.supportedInterfaceOrientations + return navigationController.topViewController?.supportedInterfaceOrientations + ?? super.supportedInterfaceOrientations } public func navigationControllerPreferredInterfaceOrientationForPresentation( _ navigationController: UINavigationController ) -> UIInterfaceOrientation { - return (navigationController.topViewController as? SPKViewController)? + return navigationController.topViewController? .preferredInterfaceOrientationForPresentation - ?? navigationController.preferredInterfaceOrientationForPresentation + ?? super.preferredInterfaceOrientationForPresentation } }