如何解决在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,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.
}
解决方法
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。