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方法用代码删除它时,我得到错误,说我被禁止删除这个目录中的文件。

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


当前回答

在AppDelegate中试试

    if #available(iOS 13.0, *) {
        do {
            try FileManager.default.removeItem(atPath: NSHomeDirectory()+"/Library/SplashBoard")
        } catch {
            print("Failed to delete launch screen cache: \(error)")
        }
    } else {
        print("ios is min")
    }

其他回答

也有这个问题。作为一个新手,我很天真地改变了启动屏幕。故事板到LaunchScreen.xib。运行失败了(呸),所以我把它改回。storyboard重新运行了应用程序,只是为了测试我没有搞砸任何其他事情——旧的屏幕没有首先出现。所以不管我做了什么,它一定把旧缓存冲出来了。

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

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

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

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

我可以确认@JERC起作用了,这要感谢arsenkin

在我的情况下,我在一个react原生项目上工作,在ios/projectname中有一个.storyboard文件,我只是想用相同的大小替换旧的图像,并保留旧的约束。我不希望用户删除应用程序或重新启动他们的手机。

我做了什么

复制图像到项目src(在我的情况下,我把我的在src/assets)。 打开查找器,将图像拖到xcode项目到项目目录。 会有一个弹出窗口,确保你创建了一个项目的引用。在这里 将.storyboard中的图像src更改为引用的图像。在这里 清理构建文件夹。在这里 重建应用程序

首先

清洁与建造项目

方法1: 重命名LaunchScreen.storyboard中加载的Splash图像。

例如,我加载了“splash”,但将其更改为“splashNew”。

方法2:

在不同的设备或模拟器上运行应用程序

例如,如果你在模拟器iphone 11中运行应用程序,那么将它运行到iphone 12中