views:

74

answers:

2

Hello,

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,

A: 

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;

Peter DeWeese
A: 

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.

AveragePro
so select your answer as the right answer by ticking it.
Pavan