At time of application:didFinishLaunchingWithOptions:
in AppDelegate, your app is ready to display the root controller, defined via code in that method itself or in IB if you are using storyboard.
If you call the webservice synchronously, within application:didFinishLaunchingWithOptions:
, your application will stay on the splash screen, but this is not a good practice, it will block the user interface.
Then, in your root controller, while waiting for the data to be returned from the service, do the following:
NO CODE:
#import "ViewController.h"
@interface ViewController ()
// crie uma propriedade para poder acessa-la no retorno dos dados do serviço.
@property (strong, nonatomic) UIView *splashScreenView;
@end
@implementation ViewController
- (void)viewDidLoad
{
[super viewDidLoad];
// Cria a splash view
self.splashScreenView = [[UIView alloc] initWithFrame:self.view.bounds];
// define o background
self.splashScreenView.backgroundColor = [UIColor colorWithPatternImage:[UIImage imageNamed:@"splash-screen"]];
// cria o spinner
UIActivityIndicatorView *loading = [[UIActivityIndicatorView alloc] initWithActivityIndicatorStyle:UIActivityIndicatorViewStyleGray];
[loading startAnimating];
// adiciona o spinner na splash view
[self.splashScreenView addSubview:loading];
// posiciona o spinner no centro da splash view.
loading.center = self.splashScreenView.center;
// adiciona a splash view na view do controller
[self.view addSubview:self.splashScreenView];
}
- (void)meusDadosDoWebserviceRetornaAqui
{
// quando receber seus dados, remova a splash view da view do controller.
[self.splashScreenView removeFromSuperview];
}
Of course, you can do all this with some coolness, like an animation and such ... In addition to this View you can also do it in IB with a NIB file.
There it is with you!
And the result is this below: