iPhone SDK - 显示图像直到后台任务完成
如何添加一个在后台任务完成之前显示的视图(相关任务填充视图并需要约 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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
将 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 callmyImageView.hidden = YES;
好吧,经过多次尝试和错误,我找到了解决方案。就我而言,我想在 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.