views:

729

answers:

2

Hello my code posted below is not dismissing my view no matter what i try. You can see my attempts to release the view in the hide splash function at the bottom. Please if anyone can help it would be greatly appreciated.

Thanks in Advance -- Zen

//
//  SplashViewController.m
//  Splash
//

#import "SplashViewController.h"

@implementation SplashViewController

- (void) didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
}

- (void) viewDidUnload {

}

- (void) dealloc {
    [super dealloc];
}

-(void) showSplash {
    modalViewController = [[UIViewController alloc] init];
    modalViewController.view = modelView;
    [self presentModalViewController:modalViewController animated:NO];
    [activityIndicator startAnimating ];
    //[self bigcalculation];
    //[self performSelector:@selector(hideSplash) withObject:nil afterDelay:2.0];
}

- (void) viewDidAppear:(BOOL)animated {
    NSLog(@"View Did Appear");
    [self bigcalculation];
}

- (void) bigcalculation {
    NSLog(@"Big Calc Start");
    for (int i = 0; i <= 648230; i++) {
        for (int j = 0; j <= 1200; j++) {

        }
    }
    NSLog(@"Big Calc End");
    [self performSelector:@selector(hideSplash) withObject:nil];
}

- (void) hideSplash {
    NSLog(@"Hide");
    //[self dismissModalViewControllerAnimated:NO];
    //[[self parentViewController] dismissModalViewControllerAnimated:YES];
    [[self modalViewController] dismissModalViewControllerAnimated:YES];
    NSLog(@"End Hide");
}

@end
+1  A: 

The modal view controller is not responsible for dismissal. That burden is placed on the view controller that called the modalViewController.

Try replacing:

[[self modalviewController] dismissModalViewControllerAnimated:YES];

with

[self dismissModalViewControllerAnimated:YES];
CrystalSkull
Look at my code i have tried that already that is why is is commented out.
Zen_silence
A: 

I found the solution in case anyone else has this issue the line

[self performSelector:@selector(hideSplash) withObject:nil];

Should be

[self performSelector:@selector(hideSplash) withObject:nil afterDelay:0.0];
Zen_silence