Skip to content

Commit 7b74440

Browse files
author
abyyxwang
committed
fix bug.
1 parent 745c5d3 commit 7b74440

File tree

1 file changed

+9
-5
lines changed

1 file changed

+9
-5
lines changed

Source/Utils/WindowUtils.swift

+9-5
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
// WindowUtils.swift
33
// TUIKitCommon
44
//
5-
// Created by 于西巍 on 2023/10/16.
5+
// Created by krab on 2023/10/16.
66
//
77

88
import Foundation
@@ -18,7 +18,7 @@ public class WindowUtils {
1818
}
1919
return UIApplication.shared.windows.first
2020
}
21-
21+
2222
public static func getCurrentWindowViewController() -> UIViewController? {
2323
var keyWindow: UIWindow?
2424
for window in UIApplication.shared.windows {
@@ -53,8 +53,12 @@ public class WindowUtils {
5353
}
5454

5555
public static var isPortrait: Bool {
56-
guard let isPortrait = UIApplication.shared.windows.first?.windowScene?.interfaceOrientation.isPortrait as? Bool
57-
else { return UIDevice.current.orientation.isPortrait }
58-
return isPortrait
56+
if #available(iOS 13.0, *) {
57+
guard let isPortrait = UIApplication.shared.windows.first?.windowScene?.interfaceOrientation.isPortrait as? Bool
58+
else { return UIDevice.current.orientation.isPortrait }
59+
return isPortrait
60+
} else {
61+
return UIDevice.current.orientation.isPortrait
62+
}
5963
}
6064
}

0 commit comments

Comments
 (0)