0

I have this app that has tabs and each tab's root view controller is a navigation controller. I want to display my splash screen or launch image while the app is busy parsing JSON and loading it up in my core data stack and remove it from superview using a fade out animation. I tried this code to make it work but I'm stuck since the image is only displayed on the view inside the navigation controller. What I wanted is to view it full screen with the status bar on top like what you see when launching an app.

_launchImageView = [[UIImageView alloc] initWithFrame:[UIScreen mainScreen].bounds];

if (kFourInchDevice) {
    _launchImageView.image = [UIImage imageNamed:@"Default-568h@2x.png"];
}

[self.view addSubview:_launchImageView];
[self.view bringSubviewToFront:_launchImageView];

And this is my code when dismissing it:

[UIView beginAnimations:nil context:nil];
[UIView setAnimationDuration:1.0];
[UIView setAnimationCurve:UIViewAnimationCurveLinear];
[UIView setAnimationTransition:UIViewAnimationTransitionNone forView:self.view cache:YES];
[UIView setAnimationDelegate:self];
[UIView setAnimationDidStopSelector:@selector(launchImageFadeAnimationDidFinished)];
_launchImageView.alpha = 0.0;
[UIView commitAnimations];

- (void)launchImageFadeAnimationDidFinished
{
    [_launchImageView removeFromSuperview];
}

Any ideas on how to do this? Thanks!

jaytrixz
  • 4,059
  • 7
  • 38
  • 57

1 Answers1

1

I think you are having problem of hiding NavBar in splash screen isnt it ? Just Add one extra ViewController in your story board. Then under Utilities ( left side bar ) under Attribute Tab - View Controller make VC initial View Controller.

Call following in your View Did Load

- (void) hideNavBar {
UINavigationBar *navBar = self.navigationController.navigationBar;
    navBar.hidden = TRUE;
}

Then when you you finish your json parser -

#pragma mark - Delegates
#pragma mark JSON Request

-(void) connectionReady; {

 NextVC *viewController = [self.storyboard
                                                 instantiateViewControllerWithIdentifier:@"NextVC"];
        [self.navigationController pushViewController:viewController
                                             animated:YES];
}

Then finally in NextVC

- (void) showNavBar {
    UINavigationBar *navBar = self.navigationController.navigationBar;
    navBar.hidden = FALSE;
}
Bishal Ghimire
  • 2,580
  • 22
  • 37
  • I was kinda hoping if there are alternatives to creating a separate `UIViewController` but it seems it's the only way. I can't make this view the initial view since I'm using tabs. – jaytrixz Oct 04 '13 at 02:21
  • 1
    Yes you can follow this http://stackoverflow.com/questions/9028534/launching-a-login-view-before-the-tab-bar-controller-is-displayed – Bishal Ghimire Oct 04 '13 at 05:53