I have an app where I recently replaced the launch images and app icons, I removed all of the old assets from everywhere in the project. When I upgrade the app from the old version to the new version by just building in Xcode, everything is fine. However, if I have the old version of my app installed then upgrade it from TestFlight, every time I kill the app then restart it the old launch image briefly appears before showing the new launch image. Similarly when I then close the app, the old app icon briefly flashes before switching back to my new one.

我使用iExplorer打开应用,并注意到/Library/Caches/Shapshots目录中保存了旧的启动屏幕图像(我不知道它是如何或为什么会出现在那里)。当我通过iExplorer手动删除它时,它就不再出现了。但是,当我尝试使用NSFileManager方法用代码删除它时,我得到错误,说我被禁止删除这个目录中的文件。

有人有过这样的经历吗?有什么建议吗?


当前回答

模拟器或实际设备 你只需要遵循这些步骤。

从xc资产中移除你的飞溅。 拖放png或jpg文件到根。 LaunchScreen。Xib或故事板。打开ViewController并设置ImageView ref你拖动的特定图像。

如果你没有ViewController,使用旧版本的react,你会在那里发现名为View。移除它,创建新的ViewController以防那个视图没有显示你的Splash。

其他回答

我也面临着同样的问题。这是因为模拟器/ iOS设备在你第一次启动应用程序时缓存了启动图像。我对Brian Trzupek的回答做了一些修改:

删除图像集从Xcode资产(例如。launch_image) 添加一个新的图像集,并向其添加图像。 关闭并打开iOS设备。(重置模拟器的内容和设置)。 清除Xcode构建文件夹(按command + option + shift + K)。 从设备/模拟器中删除应用(如果可用)。 再次运行。

这个对我很有用:http://arsenkin.com/launch_screen_image_cache.html

再一次,感谢我上面提到的帖子,我找到了一种方法 解决这个问题-命名你的新图像不同于那里的一个 以防你的新名字和旧名字一样 把它从*里拿出来。Xcassets文件夹到项目目录和 在UIImageView中引用它。就是这样。听起来很傻很简单 天啊,我有多愤怒。

使用这段代码清理启动屏幕缓存:

import UIKit

public extension UIApplication {
    func clearLaunchScreenCache() {
        #if DEBUG
        do {
            let launchScreenPath = "\(NSHomeDirectory())/Library/SplashBoard"
            try FileManager.default.removeItem(atPath: launchScreenPath)
        } catch {
            print("Failed to delete launch screen cache - \(error)")
        }
        #endif
    }
}

用法:

UIApplication.shared.clearLaunchScreenCache()

只要连接你的设备,进入Xcode >窗口>设备>你的设备, 现在在安装的应用程序中,选择你的应用程序,右键单击并下载容器,转到生成的文件,右键单击,显示包内容,AppData,库,缓存,并删除文件。 现在转到Xcode >窗口>设备>你的设备>你的应用,右键点击替换容器。

对于模拟器,只需重置内容和设置…