为什么我的 iPhone 应用程序加载延迟?
我注意到有些 iPhone 应用程序会立即显示标题屏幕。 还有一些应用程序会让您出现短暂的黑屏/空白屏幕。
我遇到了后一个问题,但它持续了大约 2 秒。 我想显示一个 PNG 图像(大小超过 200 KB)和一个加载指示器视图。
我的应用程序是基于 UIView 的。指定了一个自定义 UIView,它基本上加载并渲染所述图像作为壁纸。
我尝试不加载此图像,但加载仍然有 2 秒的延迟时间。 应用程序委托基本上将视图控制器的视图设置为子视图。
这种延迟仅在设备上可见,在模拟器上看不到。 我在看什么?
I noticed some iPhone apps give you the title screen instantly.
Then there are some apps that gives you a black/blank screen for a brief moment.
I have the latter issue, but its lasting about 2 seconds.
I would like to display a PNG image (over 200 KB size) and a loading indicator view.
My app is based on UIView. The specified a custom UIView that basically loads and renders the said image as the wallpaper.
I tried not loading this image, yet im still getting a 2 second delay time to load.
The app delegate basically sets the view controller's view as a subview.
This delay is only seen on the device, not on the simulator.
What am i over-seeing?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
如果您将 Default.png 文件放入主包中,它将在启动时显示,从点击应用程序到您将其替换为另一个视图。
您在模拟器中看不到它的原因是它加载应用程序的速度更快。
如果您想显示进度指示器,则只能在调用 appDidFinishLaunching 后才能执行此操作,但您看到的延迟仍然存在。
我使用的一个技巧是在 appDidFinishLaunching 中再次显示相同的 Default.png,然后在其顶部绘制一个进度条。当然,在初始延迟期间仍然存在静态显示,但从那里开始,直到加载所有初始视图为止,我会显示一个进度条。
最近 StackOverflow 上有一些关于此问题的讨论,您应该看看。请参阅以下内容:如何让您的 iPhone 应用程序启动更快
If you place a Default.png file in your mainbundle, it gets displayed at launch time between the time that the app is tapped on till the time that you replace it with another view.
The reason you don't see it in the simulator is because it is faster at loading your app.
If you want to display a progress indicator, you will only be able to do it once the appDidFinishLaunching is called, but the delay that you are seeing is still there.
One trick I use is to have the same Default.png displayed again in appDidFinishLaunching and then draw a progress bar on top of that. Sure there is still the static display during the initial delay, but from there until all my initial views are loaded, I display a progress bar.
There have been some recent discussions about this on StackOverflow that you should see. And see this: How To Make Your iPhone App Launch Faster