This is certainly nothing but I’m in trouble with a UIView that doesn’t show up immediatly.
Here is the code :
SettingViewController.m
- (IBAction)reloadParametersDB:(id)sender {
LoadingView* loadingView = [LoadingView loadLoadingIntoView:self.view];
[dbService fillParametersTables];
[loadingView removeLoading];
}
LoadingView.m
+(LoadingView *)loadLoadingIntoView:(UIView *)superView{
LoadingView *loadingView = [[LoadingView alloc] initWithFrame:superView.bounds];
if (loadingView == nil) return nil;
loadingView.backgroundColor = [UIColor blackColor];
[superView addSubview:loadingView];
return loadingView;
}
It works because when I’m printing something in loadLoadingIntoView I’m seeing it, and actually the problem is that the addSubview is effective after fillParametersTables is done …
Does anyone know how to do it ?
Thanks !
You need to return to the event loop in order to have your display update. One way would be to put the lines after you set up the loading view into their own method and then use
performSelector:withObject:afterDelay:to execute it.E.g.:
(This code was written inside an HTML form and may not even compile…but it should give an idea of the strategy.)