简体   繁体   中英

Initial waiting view controller

I need a way of having a initial view controller waiting with an image or something until I download all the information that the apps need.

And once it has finished downloading, go to the real main screen (in my case a TabBAr Controller )

I am trying to do it with normal segues but I can´t doit unless I embed the waiting controller on a Navigation Controller , which I think it isn't the best way.

在此处输入图片说明

Any clue on which is the best way of doing this?

Thanks in advance

The way i would be doing this is by adding a UIView containing UIImageView and UIActivityIndicatorView to it, when you start downloading and removing the view from the view controller when downloading is finished. All by coding

    UIView *loadingView = [[UIView alloc] initWithFrame:[UIScreen mainScreen].bounds];
    [loadingView setTag:99];

    UIImageView *imageView = [[UIImageView alloc] initWithFrame:loadingView.frame];
    [imageView setUserInteractionEnabled:TRUE];
    [imageView setImage:[UIImage imageNamed:@"NAME OF IMAGE"]];
//    [loadingView addSubview:imageView];

    UIActivityIndicatorView *activity = [[UIActivityIndicatorView alloc] initWithActivityIndicatorStyle:UIActivityIndicatorViewStyleGray];
    [activity setFrame:CGRectMake(imageView.center.x - 10, imageView.center.y - 10, 20, 20)];
    [imageView addSubview:activity];
    [loadingView addSubview:imageView];
    [self.view.window addSubview:loadingView];

And when downloading finishes you can remove this view like this

[[self.view.window viewWithTag:99] removeFromSuperview];

This all is to be done in the first view controller you are showing.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM