I tried to create a SplashView which display the Default.png in the background and a UIProgressBar in front. But the splash screen is not being updated...
Inside my view controller I load first the splash view with a parameter how many steps my initialisation has and then I start a second thread via NSTimer and after each initialisation step I tell the SplashView to display the new progress value.
All looks good in theory, but when running this app the progress bar is not being updated (the method of the splash screen receives the values, I can see it in the logs). I also tried to add usleep(10000); in between to give the view updates a bit time and also instead of using the progress bar I drew directly on the view and called [self setNeedsDisplay]; but all didn't work :/
What am I doing wrong?
Thanks for your help!
Tom
Here is some code:
SPLASHSCREEN: - (id)initWithFrame:(CGRect)frame withStepCount:(int)stepCount { if (self = [super initWithFrame:frame]) { // Initialization code background = [[UIImageView alloc] initWithFrame: [self bounds]]; [background setImage: [UIImage imageWithContentsOfFile: [NSString stringWithFormat:@"%@/%@", [[NSBundle mainBundle] resourcePath], @"Default.png"]]]; [self addSubview: background]; progressView = [[UIProgressView alloc] initWithProgressViewStyle:UIProgressViewStyleBar]; [progressView setFrame:CGRectMake(60.0f, 222.0f, 200.0f, 20.0f)]; [progressView setProgress: 0.0f]; stepValue = 1.0f / (float)stepCount; [self addSubview:progressView]; } return self; } - (void)tick { value += stepValue; [progressView setProgress: value]; } VIEWCONTROLLER: - (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil { if (self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil]) { splashView = [[SplashView alloc] initWithFrame: CGRectMake(0.0f, 0.0f, 320.0f, 480.0f) withStepCount:9]; [self setView: splashView]; NSTimer* delayTimer; delayTimer = [NSTimer scheduledTimerWithTimeInterval:0.05 target:self selector:@selector(finishInitialization) userInfo:nil repeats:NO]; } return self; } - (void)finishInitialization { // do some stuff, like allocation, opening a db, creating views, heavy stuff... [splashView tick]; // this should update the progress bar... // do some stuff, like allocation, opening a db, creating views, heavy stuff... [splashView tick]; // this should update the progress bar... // init done... set the right view and release the SplashView }