I've got the following code fragment (for illustration purpose):
- (IBAction)buttonPress:(id)sender {
UIView *overlayView = [[UIView alloc] initWithFrame:[UIScreen mainScreen].bounds];
overlayView.backgroundColor = [UIColor colorWithRed:0 green:0 blue:0 alpha:0.5];
UIActivityIndicatorView *activityIndicator = [[UIActivityIndicatorView alloc] initWithActivityIndicatorStyle:UIActivityIndicatorViewStyleWhite];
activityIndicator.center = overlayView.center;
[overlayView addSubview:activityIndicator];
[self.navigationController.view addSubview:overlayView];
//[self.navigationController.view bringSubviewToFront:overlayView];
[activityIndicator startAnimating];
sleep(10);
//[overlayView removeFromSuperview];
}
I wonder why the overlay view is only displayed after the method returns...