Skip to content

Commit

Permalink
fix bug.
Browse files Browse the repository at this point in the history
  • Loading branch information
abyyxwang committed May 16, 2024
1 parent 745c5d3 commit 7b74440
Showing 1 changed file with 9 additions and 5 deletions.
14 changes: 9 additions & 5 deletions Source/Utils/WindowUtils.swift
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
// WindowUtils.swift
// TUIKitCommon
//
// Created by 于西巍 on 2023/10/16.
// Created by krab on 2023/10/16.
//

import Foundation
Expand All @@ -18,7 +18,7 @@ public class WindowUtils {
}
return UIApplication.shared.windows.first
}

public static func getCurrentWindowViewController() -> UIViewController? {
var keyWindow: UIWindow?
for window in UIApplication.shared.windows {
Expand Down Expand Up @@ -53,8 +53,12 @@ public class WindowUtils {
}

public static var isPortrait: Bool {
guard let isPortrait = UIApplication.shared.windows.first?.windowScene?.interfaceOrientation.isPortrait as? Bool
else { return UIDevice.current.orientation.isPortrait }
return isPortrait
if #available(iOS 13.0, *) {
guard let isPortrait = UIApplication.shared.windows.first?.windowScene?.interfaceOrientation.isPortrait as? Bool
else { return UIDevice.current.orientation.isPortrait }
return isPortrait
} else {
return UIDevice.current.orientation.isPortrait
}
}
}

0 comments on commit 7b74440

Please sign in to comment.