简体   繁体   English

在iOS上生成随机默认屏幕

[英]Generating a random default screen on iOS

One of the prerequisites within Xcode is setting the 'Default' and 'Default@2x' images for when the iPhone app loads up. Xcode中的一个先决条件是设置iPhone应用程序加载时的“默认”和“默认@ 2x”图像。

Is it all possible to have a number of Default screens made, inserted into the project in png format and each time the app is loaded, choose a random default screen to use? 是否可以制作一些默认屏幕,以png格式插入项目,每次加载应用程序时,选择一个随机默认屏幕使用?

You can change the default screen in iOS (at least after first launch) by setting UILaunchImageFile property in the info.plist, and then writing a new image to the Documents folder. 您可以通过在info.plist中设置UILaunchImageFile属性,然后将新图像写入Documents文件夹来更改iOS中的默认屏幕(至少在首次启动后)。

eg. 例如。

<key>UILaunchImageFile</key>
<string>../Documents/NewDefault.png</string> 

then write your random splash to /Documents/NewDefault.png . 然后将随机启动写入/Documents/NewDefault.png


Seems i have to be more prescriptive... I am not suggesting you modify anything in your app bundle at runtime, as has been said, that cannot occur. 似乎我必须更具说明性......我不是建议你在运行时修改你的应用程序包中的任何东西,正如已经说过的那样,不会发生。

But because the /Documents folder sits next to the .app folder, you can set the UILaunchImageFile via a relative path, and then put a file at the path specified when the app runs. 但是因为/Documents文件夹位于.app文件夹旁边,所以可以通过相对路径设置UILaunchImageFile ,然后将文件放在应用程序运行时指定的路径上。 We have done this, and it works, so before you down vote, try it yourself. 我们已经做到了这一点,并且它有效,所以在你投票之前,请自己尝试一下。

You cannot change Default.png. 你不能改变Default.png。 Once the app is shipped - it's "set in stone". 一旦应用程序发货 - 它就是“一成不变”。 Until the next release, that is. 直到下一个版本,就是这样。 The reason is simple (and same why you can't change apps icon). 原因很简单(同样为什么你不能改变应用程序图标)。 App's bundle is read-only. App的捆绑包是只读的。 It is made read only because it is signed by you and by apple. 它是只读的,因为它是由你和苹果签署的。 Modifying the contents of the bundle would invalidate the signature. 修改包的内容将使签名无效。

There is no way to change the startup screen without rebuilding the app. 没有重建应用程序就无法更改启动屏幕。 It's name is either hardcoded in info plist or is set to the default value of "Default.png" if nothing is set in the plist. 如果plist中没有设置任何内容,则其名称可以在info plist中进行硬编码,也可以设置为默认值“Default.png”。

Since both the image file and plist file are inside app's bundle which is digitally signed, even if you could change any of them (you can't as it's read-only), your app's signature would invalidate and crash on non-jailbroken devices. 由于图像文件和plist文件都在数字签名的应用程序包中,即使您可以更改它们中的任何一个(您不能只读它),您的应用程序的签名将在非越狱设备上失效并崩溃。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM