ios - iOS13 App黑屏,self.window不工作
问题描述
在我的测试 iPhone 设备升级到版本 13.3 后,我self.window
的不再工作了。我试过如下:
选择目标 -> 常规 -> 部署信息,清理“主界面”。
删除了 info.plist 中的“故事板名称 -> main”,删除了 info.plist 中的“主故事板文件基本名称”,删除了 info.plist 中与 main.storyboard 相关的任何内容。
在 didFinishLaunchingWithOptions 中添加代码:
self.window = [[UIWindow alloc] initWithFrame:[UIScreen mainScreen].bounds];
self.window.backgroundColor = KWhiteColor;
[self.window makeKeyAndVisible];
但是启动App还是黑屏。有没有人可以告诉我为什么以及如何进行self.window
工作?
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
// Override point for customization after application launch.
//初始化window
// [self initWindow];
self.window = [[UIWindow alloc] initWithFrame:[UIScreen mainScreen].bounds];
self.window.backgroundColor = KWhiteColor;
[self.window makeKeyAndVisible];
//初始化服务
[self initService];
//初始化用户系统
// [self initUserManager];
CSKLoginViewController *vc = [CSKLoginViewController new];
// vc.showBack = NO;
// RootNavigationController *loginNavi = [[RootNavigationController alloc] initWithRootViewController:vc];
vc.view.backgroundColor = UIColor.redColor;
self.window.rootViewController = vc;
return YES;
}
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>CFBundleDisplayName</key>
<string>xxx</string>
<key>CFBundleDevelopmentRegion</key>
<string>zh_CN</string>
<key>CFBundleExecutable</key>
<string>$(EXECUTABLE_NAME)</string>
<key>CFBundleIdentifier</key>
<string>$(PRODUCT_BUNDLE_IDENTIFIER)</string>
<key>CFBundleInfoDictionaryVersion</key>
<string>6.0</string>
<key>CFBundleName</key>
<string>$(PRODUCT_NAME)</string>
<key>CFBundlePackageType</key>
<string>$(PRODUCT_BUNDLE_PACKAGE_TYPE)</string>
<key>CFBundleShortVersionString</key>
<string>1.0</string>
<key>CFBundleVersion</key>
<string>1</string>
<key>LSRequiresIPhoneOS</key>
<true/>
<key>NSAppTransportSecurity</key>
<dict>
<key>NSAllowsArbitraryLoads</key>
<true/>
</dict>
<key>NSCameraUsageDescription</key>
<string></string>
<key>NSContactsUsageDescription</key>
<string>访问您的通讯录新增客户。</string>
<key>NSMicrophoneUsageDescription</key>
<string></string>
<key>NSPhotoLibraryUsageDescription</key>
<string></string>
<key>UIApplicationSceneManifest</key>
<dict>
<key>UIApplicationSupportsMultipleScenes</key>
<false/>
<key>UISceneConfigurations</key>
<dict>
<key>UIWindowSceneSessionRoleApplication</key>
<array>
<dict>
<key>UISceneConfigurationName</key>
<string>Default Configuration</string>
<key>UISceneDelegateClassName</key>
<string>SceneDelegate</string>
</dict>
</array>
</dict>
</dict>
<key>UILaunchStoryboardName</key>
<string>LaunchScreen</string>
<key>UIRequiredDeviceCapabilities</key>
<array>
<string>armv7</string>
</array>
<key>UISupportedInterfaceOrientations</key>
<array>
<string>UIInterfaceOrientationPortrait</string>
<string>UIInterfaceOrientationLandscapeLeft</string>
<string>UIInterfaceOrientationLandscapeRight</string>
</array>
<key>UISupportedInterfaceOrientations~ipad</key>
<array>
<string>UIInterfaceOrientationPortrait</string>
<string>UIInterfaceOrientationPortraitUpsideDown</string>
<string>UIInterfaceOrientationLandscapeLeft</string>
<string>UIInterfaceOrientationLandscapeRight</string>
</array>
</dict>
</plist>
解决方案
问题是你的代码放错了地方。窗口不再属于应用委托;它属于场景委托。
推荐阅读
- javascript - 帖子正文中缺少必需的参数 To
- regex - 正则表达式字母数字,但当它得到一个数字时,那么只有数字
- python - 如何通过numpy在每一行中加载不同数量的字符串元素
- c - scanf存储值太长,它读取的第二个值存储两次
- flutter - 缺少静态目标的未实现处理,Flutter
- javascript - React.js 你如何连接来自状态的动态文本
- node.js - 更新到 discord.js v12,无法列出所有公会
- html - 快速路由以提供静态内容目录
- php - 无论出于何种原因,PHP 7.4.4 都不想针对路径 php_mysqli.dll(Windows 10 Server 版本)
- javascript - 单击图像时隐藏图像