Ios 为什么在Xcode 12.1中将部署目标设置为11.0时,我的应用程序会变暗?

Ios 为什么在Xcode 12.1中将部署目标设置为11.0时,我的应用程序会变暗?,ios,swift,xcode,xcode12,Ios,Swift,Xcode,Xcode12,我正在使用最新的Xcode(12.1)创建一个新项目。创建新项目时的默认部署目标是14.1。然后我把它改成11.0。因为我想瞄准iOS 11.0及以上版本的用户 然后它会在myAppDelegate和SceneDelegate 我修复了所有这些问题,因此我的AppDelegate和SceneDelegate将与下面的代码类似 问题是 当我在我的真实设备iOS 14.1上运行它时,它不会有任何问题。但当我在iOS 12.4.8上运行它时,我的应用程序将完全黑暗 我已经用这个键关闭了info.p

我正在使用最新的Xcode(12.1)创建一个新项目。创建新项目时的默认部署目标是14.1。然后我把它改成11.0。因为我想瞄准iOS 11.0及以上版本的用户

然后它会在my
AppDelegate
SceneDelegate

我修复了所有这些问题,因此我的
AppDelegate
SceneDelegate
将与下面的代码类似

问题是

当我在我的真实设备iOS 14.1上运行它时,它不会有任何问题。但当我在iOS 12.4.8上运行它时,我的应用程序将完全黑暗

我已经用这个键关闭了info.plist中的暗模式

<key>Appearance</key>
<string>Light</string>
AppDelegate.swift

class SceneDelegate: UIResponder, UIWindowSceneDelegate {

    var window: UIWindow?


    @available(iOS 13.0, *)
    func scene(_ scene: UIScene, willConnectTo session: UISceneSession, options connectionOptions: UIScene.ConnectionOptions) {
        // Use this method to optionally configure and attach the UIWindow `window` to the provided UIWindowScene `scene`.
        // If using a storyboard, the `window` property will automatically be initialized and attached to the scene.
        // This delegate does not imply the connecting scene or session are new (see `application:configurationForConnectingSceneSession` instead).
        guard let _ = (scene as? UIWindowScene) else { return }
    }

    @available(iOS 13.0, *)
    func sceneDidDisconnect(_ scene: UIScene) {
        // Called as the scene is being released by the system.
        // This occurs shortly after the scene enters the background, or when its session is discarded.
        // Release any resources associated with this scene that can be re-created the next time the scene connects.
        // The scene may re-connect later, as its session was not necessarily discarded (see `application:didDiscardSceneSessions` instead).
    }

    @available(iOS 13.0, *)
    func sceneDidBecomeActive(_ scene: UIScene) {
        // Called when the scene has moved from an inactive state to an active state.
        // Use this method to restart any tasks that were paused (or not yet started) when the scene was inactive.
    }

    @available(iOS 13.0, *)
    func sceneWillResignActive(_ scene: UIScene) {
        // Called when the scene will move from an active state to an inactive state.
        // This may occur due to temporary interruptions (ex. an incoming phone call).
    }

    @available(iOS 13.0, *)
    func sceneWillEnterForeground(_ scene: UIScene) {
        // Called as the scene transitions from the background to the foreground.
        // Use this method to undo the changes made on entering the background.
    }

    @available(iOS 13.0, *)
    func sceneDidEnterBackground(_ scene: UIScene) {
        // Called as the scene transitions from the foreground to the background.
        // Use this method to save data, release shared resources, and store enough scene-specific state information
        // to restore the scene back to its current state.
    }


}
@main
class AppDelegate: UIResponder, UIApplicationDelegate {



    func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {
        // Override point for customization after application launch.
        return true
    }

    // MARK: UISceneSession Lifecycle

    @available(iOS 13.0, *)
    func application(_ application: UIApplication, configurationForConnecting connectingSceneSession: UISceneSession, options: UIScene.ConnectionOptions) -> UISceneConfiguration {
        // Called when a new scene session is being created.
        // Use this method to select a configuration to create the new scene with.
        return UISceneConfiguration(name: "Default Configuration", sessionRole: connectingSceneSession.role)
    }

    @available(iOS 13.0, *)
    func application(_ application: UIApplication, didDiscardSceneSessions sceneSessions: Set<UISceneSession>) {
        // Called when the user discards a scene session.
        // If any sessions were discarded while the application was not running, this will be called shortly after application:didFinishLaunchingWithOptions.
        // Use this method to release any resources that were specific to the discarded scenes, as they will not return.
    }
@main
类AppDelegate:UIResponder、UIApplicationLegate{
func应用程序(application:UIApplication,didFinishLaunchingWithOptions launchOptions:[UIApplication.launchOptions键:任意]?)->Bool{
//应用程序启动后自定义的覆盖点。
返回真值
}
//MARK:UISceneSession生命周期
@可用(iOS 13.0,*)
func应用程序(uApplication:UIApplication,用于连接的配置SceneSession:UISceneSession,选项:UIScene.ConnectionOptions)->UISceneConfiguration{
//在创建新场景会话时调用。
//使用此方法可以选择配置以创建新场景。
返回UISceneConfiguration(名称:“默认配置”,会话角色:ConnectionSceneSession.role)
}
@可用(iOS 13.0,*)
func应用程序(application:UIApplication,didDiscardSceneSessions sceneSessions:Set){
//当用户放弃场景会话时调用。
//如果在应用程序未运行时丢弃了任何会话,则将在application:didFinishLaunchingWithOptions后不久调用该会话。
//使用此方法释放特定于被丢弃场景的任何资源,因为它们不会返回。
}
我从

您必须在AppDelegate类中添加以下属性声明

var window: UIWindow?