如何随机化启动画面?
是否有可能让 iPhone 应用程序启动画面拾取随机图像或文本?这样每次都不同(例如显示提示)?如果是这样怎么办?
Is it possible to make the iphone app splash screen pick up a random image or text? So that it is different every time (e.g. display tips)? If so how?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
这是不可能的。应用程序中的
Default.png
文件始终是“启动画面”。在构建应用程序后尝试更改它会更改应用程序的签名,并且下次运行时不会启动。 (假设您可以写入应用程序包中的文件,我还没有尝试过。)This is not possible. The
Default.png
file in your application is always the "splash screen". To try and alter it after the application has been built would alter the signature of your application, and it would not launch the next time it was run. (Assuming you can write to files within your application bundle, which I have not tried.)确实,您无法更改启动屏幕,但您可以呈现包含您想要的任何内容的视图。请勿在捆绑包中包含 Default.png 图像。然后在您的应用程序委托中,实例化一个视图控制器并将其视图作为子视图添加到 self.window 中。然后你需要关闭这个视图,要么基于计时器,要么基于启动处理的完成,或者用户点击等。
值得注意的是,Apple不鼓励使用启动屏幕,并建议你只启动UI并尽可能快地工作。如果您必须有一个启动屏幕,您可以显示一些看起来像您正在运行的应用程序的内容,以创建响应式 UI 的错觉,并在 UI 真正响应时将其删除。
It is true that you cannot alter the splash screen, but you can present a view with whatever you want in it. Don't include a Default.png image in the bundle. Then in your app delegate, instantiate a view controller and add it's view as a subview to self.window. Then you need to dismiss this view, either based on a timer, or the completion of your startup processing, or a user tap, etc.
It is worth noting that Apple discourages using a splash screen, and recommends that you just get the UI up and working as fast as possible. If you must have a splash screen, you can display something that looks like your working app to create the illusion of a responsive UI, and remove that as soon as your UI really is responding.