views:

727

answers:

0

Hello, i'm trying to remove a UIViewController from the superview after receiving a notification but it doesn't work.

in my appDelegate i do something like this:

- (void)applicationDidFinishLaunching:(UIApplication *)application{    
NSLog(@"applicationDidFinishLaunching");
[window addSubview:tabBar.view];
splash = [[SplashViewController alloc] init]; <-- this i want to remove
[window addSubview:splash.view];
[window makeKeyAndVisible]; }

in the SplashViewController i register the view to receive NSNotifications like this:

[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(fadeScreen:) name:@"CloseSplashScreen" object:nil];

the SplashViewController appears right after the Default.png and should fade smoothly after some data is parsed...

in my TableViewControler i want to send the notification in the viewWillAppear method but it doesn't work.

- (void)viewWillAppear:(BOOL)animated{
NSLog(@"viewWillAppear");
[[NSNotificationCenter defaultCenter] postNotificationName:@"CloseSplashScreen" object:self];}

the method gets called but the view is not removed from the superview. i tried to put the postNotification in - (void)viewDidLoad but the method doesn't get called...

any ideas why this is not working? thank you in advance