xgqfrms™, xgqfrms® : xgqfrms's offical website of cnblogs! xgqfrms™, xgqfrms® : xgqfrms's offical website of GitHub!

iOS App LaunchScreen storyboard not work bug All In One

iOS App LaunchScreen storyboard not work bug All In One

bug,iOS LaunchScreen storyboard 不显示图片

复现步骤 & 问题排查

  1. 删除后,新建 Launch Screen.storyboard 默认的运行成功 ✅

  1. 添加 Label View 不设置,运行成功 ✅

  1. 添加 Image View 不设置,选择 background 图片 ,运行失败 ❌ ???问题在这里

  1. 添加 Image View 不设置,选择 其他 图片 运行成功 ✅???

问题在这里
background 图片 太大; ❌
格式不支持 ???png/ jpg; ❌
文件夹名称冲突,或名称与配置文件不一致 ???❌

  1. 添加 Image View 设置,选择 其他 图片,添加 约束条件 运行成功 ✅

  1. 添加 Image View 设置,选择 Assets 文件夹外面的图片,运行成功 ✅

删除重新创建, 配置缓存 bug

BeiJingTourth.xcodeproj/project.pbxproj

/* Begin PBXFileReference section */
		70B12814282CA5AF000716FC /* 北京旅游.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = "北京旅游.app"; sourceTree = BUILT_PRODUCTS_DIR; };
		70B12817282CA5AF000716FC /* BeiJingTourthApp.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = BeiJingTourthApp.swift; sourceTree = "<group>"; };
		70B12819282CA5AF000716FC /* ContentView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ContentView.swift; sourceTree = "<group>"; };
		70B1281B282CA5B1000716FC /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = "<group>"; };
		70B1281E282CA5B1000716FC /* Preview Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = "Preview Assets.xcassets"; sourceTree = "<group>"; };
		70B1282C282D2278000716FC /* Launch Screen.storyboard */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; path = "Launch Screen.storyboard"; sourceTree = "<group>"; };
		70B1282E282D3574000716FC /* test.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; name = test.png; path = Assets.xcassets/Bug/Image.imageset/test.png; sourceTree = "<group>"; };
		70B12830282D35A1000716FC /* test-dark.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; name = "test-dark.png"; path = "Assets.xcassets/Bug/Image.imageset/test-dark.png"; sourceTree = "<group>"; };
/* End PBXFileReference section */

project.pbxproj

Info.plist

		70B12823282CA5B1000716FC /* Debug */ = {
			isa = XCBuildConfiguration;
			buildSettings = {
				ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
				ASSETCATALOG_COMPILER_GLOBAL_ACCENT_COLOR_NAME = AccentColor;
				CODE_SIGN_STYLE = Automatic;
				CURRENT_PROJECT_VERSION = 1;
				DEVELOPMENT_ASSET_PATHS = "\"BeiJingTourth/Preview Content\"";
				DEVELOPMENT_TEAM = GPGP7L32J5;
				ENABLE_PREVIEWS = YES;
				GENERATE_INFOPLIST_FILE = YES;
				INFOPLIST_FILE = BeiJingTourth/Info.plist;
                                //...
			};
			name = Debug;
		};

bug still ??? why, WTF

temporary solution ✅

使用 Assets.xcassets 外面的根目录下 image 才可以正常渲染 Launch Screen 的背景图片,Why???

https://stackoverflow.com/a/64000507/5934465

iOS 15 bug

version bug

  1. iOS 14 ✅

  1. iOS 15 ❌

??? iOS 14 ✅,然后切换到 iOS 15 突然好了✅

solutions ???

1.查看图片尺寸是否正确,是否添加约束
2.检查TARGETS → General → App Icons and Launch Images 下 Launch Screen File 设置是否是 LaunchScreen 这个同名的 storyboard 文件
3.图片资源不能放置在 Assets.xcasset 文件夹中, 要直接拖拽到与 Assets.xcasset 文件夹同层的项目根目录下 ✅, 可以但是不推荐,无法自适应 Dark 模式 👎
4.卸载 app,重新构建 Command+R

  1. 可以通过清理以下文件夹编译缓存文件 ✅
    ~/Library/Developer/Xcode/DerivedData

  1. 清理缓存
import UIKit

public extension UIApplication {
  func clearLaunchScreenCache() {
    do {
       try FileManager.default.removeItem(atPath: NSHomeDirectory()+"/Library/SplashBoard")
    } catch {
       print("Failed to delete launch screen cache: \\(error)")
    }
}

// UIApplication.shared.clearLaunchScreenCache();

Library 文件夹中有一个名为 SplashBoard 的文件夹,该文件夹是启动屏缓存的存储位置

https://www.jianshu.com/p/1cc8b3a74f08

https://stackoverflow.com/questions/63978396/launch-screen-not-working-on-ios-14-with-xcode-12

https://developer.apple.com/forums/thread/665358

https://stackoverflow.com/questions/36947371/ios-xcode-launchscreen-storyboard-not-displaying

refs

https://developer.apple.com/design/human-interface-guidelines/ios/visual-design/launch-screen/



©xgqfrms 2012-2020

www.cnblogs.com/xgqfrms 发布文章使用:只允许注册用户才可以访问!

原创文章,版权所有©️xgqfrms, 禁止转载 🈲️,侵权必究⚠️!


posted @ 2022-05-12 18:05  xgqfrms  阅读(234)  评论(3编辑  收藏  举报