iOS 更新后保留旧的启动屏幕和应用程序图标
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/33002829/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
iOS Keeping old launch screen and app icon after update
提问by lramirez135
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.
我有一个应用程序,我最近替换了启动图像和应用程序图标,我从项目中的任何地方删除了所有旧资产。当我通过在 Xcode 中构建将应用程序从旧版本升级到新版本时,一切都很好。但是,如果我安装了旧版本的应用程序然后从 TestFlight 升级它,每次我杀死应用程序然后重新启动它时,旧的启动图像会在显示新的启动图像之前短暂出现。同样,当我关闭应用程序时,旧应用程序图标会短暂闪烁,然后再切换回我的新应用程序。
I opened up the App using iExplorer and noticed that there is an image of the old launch screen saved in the /Library/Caches/Shapshots
directory (I don't know how or why it got there). When I delete it manually through iExplorer, it stops appearing. However, when I try to remove it with code using NSFileManager
methods, I get errors saying I am forbidden from deleting files in this directory.
我使用 iExplorer 打开应用程序,注意到/Library/Caches/Shapshots
目录中保存了旧启动屏幕的图像(我不知道它是如何或为什么到达那里的)。当我通过 iExplorer 手动删除它时,它停止出现。但是,当我尝试使用NSFileManager
方法通过代码删除它时,我收到错误消息,提示我被禁止删除此目录中的文件。
Has anyone experienced this before and have any advice?
有没有人以前经历过这种情况并有任何建议?
回答by Brian Trzupek
I have been able to reliably get the springboard cache cleared for testing launch image changes by doing this:
通过这样做,我已经能够可靠地清除跳板缓存以测试启动图像更改:
- Delete your app from the device
- Power down the device
- Power up device, install and launch app.
- 从设备中删除您的应用
- 关闭设备电源
- 启动设备,安装并启动应用程序。
The image updates properly every time. Shame I need to power down the device to get it to go - but at least I have been able to make progress this way. I hope this helps someone.
图像每次都正确更新。可惜我需要关闭设备电源才能让它运行 - 但至少我已经能够以这种方式取得进展。我希望这可以帮助别人。
In case of the simulator, just restarting of simulator should work.
在模拟器的情况下,只需重新启动模拟器即可。
回答by InkGolem
These caches are used by Springboard to make app switching fast. This isn't a problem that will affect your production users and should in theory go away the next time Springboard decides to snapshot your app.
Springboard 使用这些缓存来快速切换应用程序。这不是会影响您的生产用户的问题,理论上应该在下次 Springboard 决定为您的应用程序快照时消失。
That being said, this isn't a problem you can fix. This is a bug in Apple's code not yours.
话虽如此,这不是您可以解决的问题。这是 Apple 代码中的错误,而不是您的错误。
UPDATE: There appears to be a work around that doesn't require restarting the device.
更新:似乎有一种不需要重新启动设备的解决方法。
This will take effect after the second launch!
这将在第二次启动后生效!
do {
try FileManager.default.removeItem(atPath: NSHomeDirectory()+"/Library/SplashBoard")
} catch {
print("Failed to delete launch screen cache: \(error)")
}
A full explanation of how that works here: https://rambo.codes/ios/quick-tip/2019/12/09/clearing-your-apps-launch-screen-cache-on-ios.html
其工作原理的完整解释:https: //rambo.codes/ios/quick-tip/2019/12/09/clearing-your-apps-launch-screen-cache-on-ios.html
回答by Murray Sagal
For the simulator just Reset Contents and Settings...
对于模拟器只是 Reset Contents and Settings...
回答by chinnawatp
@InkGolem
@InkGolem
This isn't a problem that will affect your production users
这不是会影响您的生产用户的问题
is true.
是真的。
I was facing this issue when I changed my Launch Screen, SplashScreen and App Icon. I tried every method, but it didn't work. Finally, I just published my app and downloaded my application from App store with the device that I didn't use for development. SplashScreen and App Icon work as normal!!!
当我更改启动屏幕、启动画面和应用程序图标时,我遇到了这个问题。我尝试了所有方法,但没有奏效。最后,我刚刚发布了我的应用程序,并使用我没有用于开发的设备从 App Store 下载了我的应用程序。启动画面和应用程序图标正常工作!!!
回答by Yu-Sen Han
I found workaround solution what if you really want to fix this issue. Apple have some mechanisms to cache images of launch screen which indexing by image file name.
如果您真的想解决此问题,我找到了解决方法。Apple 有一些机制来缓存按图像文件名索引的启动屏幕图像。
When you change any images on launch screen and you want to see those change in next run immediately. please using new image name which image you changed and link to new image file in storyboard or xib.
当您更改启动屏幕上的任何图像并且希望在下次运行时立即看到这些更改时。请使用您更改的新图像名称并链接到故事板或 xib 中的新图像文件。
Run again, you will see new change appear.
再次运行,你会看到新的变化出现。
回答by JERC
This worked for me: http://arsenkin.com/launch_screen_image_cache.html
这对我有用:http: //arsenkin.com/launch_screen_image_cache.html
Again, thanks to the thread I have referenced above I found a way to solve this issue - name your new image differently from the one there was before in case your new one has the same name as the old one and put it out of the *.xcassets folder to the project directory and reference it in your UIImageView. And that's it. Sound stupid easy but oh gawd how much rage I had.
再次,感谢我在上面引用的线程,我找到了一种解决此问题的方法 - 将您的新图像命名为与之前不同的名称,以防您的新图像与旧图像具有相同的名称并将其从 * 中删除.xcassets 文件夹到项目目录并在您的 UIImageView 中引用它。就是这样。听起来很愚蠢很容易,但天哪,我有多少愤怒。
回答by Ankit Pundhir
Uninstall your app, restart your phone and install your app again... This actually fixed in my case.
卸载您的应用程序,重新启动您的手机并再次安装您的应用程序......这在我的情况下实际上已解决。
回答by A.G
I also faced the same issue. It happens because the simulator/ iOS device caches the launch image when you first launch the application. I added some modifications to Brian Trzupek's answer:
我也面临同样的问题。发生这种情况是因为模拟器/iOS 设备在您首次启动应用程序时缓存了启动图像。我对Brian Trzupek 的回答添加了一些修改:
- Delete the image set from Xcode assets (eg. launch_image)
- Add a new image set and add images to it.
- Switch off and switch on the iOS Device. (Reset Contents and Settings for simulator).
- Clean the Xcode build folder (Press command+ option+ shift+ K).
- Delete the app from the device/simulator (if available).
- Run again.
- 从 Xcode 资产中删除图像集(例如 launch_image)
- 添加新图像集并向其中添加图像。
- 关闭并打开 iOS 设备。(重置模拟器的内容和设置)。
- 清理 Xcode 构建文件夹(按command+ option+ shift+ K)。
- 从设备/模拟器中删除应用程序(如果可用)。
- 再次运行。
回答by Daniel Springer
What didwork for me:
什么做的工作对我来说:
- Deleting the LaunchScreen's Scene and View Controller and create a new one (make sure you set it as "Initial View Controller" in the Attributes Inspector).
- 删除 LaunchScreen 的场景和视图控制器并创建一个新的(确保在属性检查器中将其设置为“初始视图控制器”)。
What did notwork for me:
什么都没有为我工作:
- Deleting the app
- Restarting the iPhone, Mac or Xcode
- Deleting Derived Data
- Deleting the device's container
- Cleaning
- Burning 3 Steve Jobs Voodoo dolls
- 删除应用程序
- 重启 iPhone、Mac 或 Xcode
- 删除派生数据
- 删除设备的容器
- 打扫
- 燃烧 3 个史蒂夫乔布斯巫毒娃娃
回答by Daniel Springer
Just connect your device, go to Xcode > Window > Devices > Your device, now in installed apps, select your app, right click and download container, go to the generated file, right click, Show package contents, AppData, Library, Caches, and delete files. Now go to Xcode > Window > Devices > Your device > your app and right click to replace containers.
只需连接您的设备,转到 Xcode > Window > Devices > Your device,现在在已安装的应用程序中,选择您的应用程序,右键单击并下载容器,转到生成的文件,右键单击,显示包内容、AppData、Library、Caches,并删除文件。现在转到 Xcode > Window > Devices > Your device > your app 并右键单击以替换容器。