ios - 当我在 Xcode 12.1 中将部署目标设置为 11.0 时,为什么我的应用程序变暗了?
问题描述
我正在使用最新的 Xcode (12.1) 创建一个新项目。我创建新项目时的默认部署目标是 14.1。然后我将其更改为 11.0。因为我想针对 iOS 11.0 及更高版本的用户
那么它会在我的AppDelegate
和SceneDelegate
我修复了所有这些,所以我的AppDelegate
和SceneDelegate
将像下面的代码一样。
问题是.....
当我在我的真实设备 iOS 14.1 上运行它时,它不会有任何问题。但是当我在 iOS 12.4.8 上运行它时,我的应用程序将完全变暗
我也已经使用这个键关闭了 info.plist 中的暗模式
<key>Appearance</key>
<string>Light</string>
如何解决这个问题?
像这样的iOS 12.4.8完全黑暗。背景颜色应该是自定义橙色
SceneDelagate.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.
}
}
AppDelegate.swift
@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.
}
解决方案
推荐阅读
- node.js - 运行节点应用程序时带有环境变量的 Docker CMD
- haskell - 如何在 Hakyll html 中为第二个帖子目录创建第二个列表?
- css - 为什么在尝试将我的 Angular 项目从基于 CSS 的项目转换为 SCSS 项目时出现此错误?
- django - 为前端图片渲染创建一个“虚拟”URL 路径
- postgresql - 按日期划分的范围分区,其中一个分区用于 NULL 日期
- directus - 如果将“多对多”字段添加到 directus_users
- javascript - 如何对齐 HTML5 表单验证气泡消息?
- vue.js - 使用组件通过 CDN 读取条码
- reporting-services - SSRS 电子邮件订阅的条件页脚
- r - 如何在 R 中构建这个 JSON 文件?