iPhone SDK - 显示图像直到后台任务完成

发布于 2024-09-19 06:21:33 字数 58 浏览 4 评论 0原文

如何添加一个在后台任务完成之前显示的视图(相关任务填充视图并需要约 5 秒)。

谢谢,

How can I go about adding a view that appears until the background task finishes (the task in question populates a view and takes ~5 seconds).

Thanks,

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

同展鸳鸯锦 2024-09-26 06:21:33

将 xib 中的隐藏图像视图连接到 IBOutlet,并在任务开始之前显示它并在任务结束时隐藏它。 xib 检查器的视图部分中有一个“隐藏”选项。在调用任务之前,使用 myImageView.hidden = NO;。根据后台任务是什么,您应该能够为该任务的所有者提供一个可以调用 myImageView.hidden = YES; 的闭包块、委托或选择器

Wire a hidden image view in the xib to an IBOutlet, and simply show it before the task starts and hide it when it is over. There is a "hidden" option in the xib inspector's view section. Just before you call the task, use myImageView.hidden = NO;. Depending on what the background task is, you should be able to give the owner of that task a closure block, delegate, or selector that can call myImageView.hidden = YES;

丿*梦醉红颜 2024-09-26 06:21:33

好吧,经过多次尝试和错误,我找到了解决方案。就我而言,我想在 tabbarviewcontroller 初始化时显示一个视图,由于其中的内容,这需要 5 - 10 秒。因此,为了改善用户体验,我希望出现一个图像。彼得,不幸的是,您发布的方法并没有完全解决问题,因为尽管调用视图使其处于视图中,直到调用选项卡视图后才显示它,但它会自动删除。

因此,我所做的是将 NSTimer 设置为 10 秒,并在 10 秒后隐藏视图。确保我设置了 [self.window BringSubviewToFront:imageview]; 以确保选项卡栏不会出现在加载视图上。

Okay, after much trial and error I found a solution. In my case I wanted to show a view whilst my tabbarviewcontroller initialised, and due to the content within it this took 5 - 10 seconds. So to improve user experience I wanted an image to appear. Peter, the method you posted unfortunately didn't quite solve the problem as despite calling the view to be in view until after the tabview was called to appear, it was removed automatically.

So, what I did was set up an NSTimer for 10 seconds, and after the 10 seconds hide the view. Making sure I had [self.window bringSubviewToFront:imageview]; set to insure the tabbar didn't appear over the loading view.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文