我有一个iOS应用程序,可以在外部显示器上显示大部分数据(通过Airplay或物理电缆连接)。是否可以在外接显示器上显示设备的状态栏?以下是我如何初始化外部显示器:
func checkForExistingScreenAndInitializeIfPresent() -> UIViewController? {
if UIScreen.screens.count > 1 {
if let secondScreen = UIScreen.screens.last {
return initializeSecondScreen(with: secondScreen)
}
}
return nil
}
func initializeSecondScreen(with secondScreen: UIScreen) -> UIViewController? {
let screenBounds = secondScreen.bounds
secondWindow = UIWindow(frame: screenBounds)
secondWindow?.screen = secondScreen
secondWindow?.isHidden = false
secondWindow?.rootViewController = UIStoryboard(name: "Main", bundle: nil).instantiateViewController(withIdentifier: "homeViewController")
return secondWindow?.rootViewController
}
我的HomeViewController中有以下代码。
override var prefersStatusBarHidden: Bool {
return false
}
override var preferredStatusBarStyle: UIStatusBarStyle {
return .default
}
状态栏在HomeViewController的iOS应用程序中显示正常,但在HomeViewController显示在外部显示器上时从未显示。