views:

1190

answers:

2

I have following code in my Application.

Comments in my code will specify "My Question".

- (void)applicationDidFinishLaunching:(UIApplication *)application {    
tabBarObj = [[UITabBarController alloc] init];

vctr0=[[SplashScrn alloc] initWithNibName:@"SplashScrn" bundle:nil];
vctr1=[[SearchViewController alloc] initWithNibName:@"SearchViewController" bundle:nil];
vctr2=[[RootViewController alloc] initWithNibName:@"RootViewController" bundle:nil];

UINavigationController *nvctr1=[[[UINavigationController alloc]initWithRootViewController:vctr1] autorelease];
UINavigationController *nvctr2=[[[UINavigationController alloc]initWithRootViewController:vctr2] autorelease];

tabBarObj.viewControllers=[NSArray arrayWithObjects:nvctr1,nvctr2,nil];
[window addSubview:vctr0.view];
[window makeKeyAndVisible];

[NSTimer scheduledTimerWithTimeInterval:0.5 target:self selector:@selector(hideSplash) userInfo:nil repeats:NO];
}

-(void)hideSplash
{
/* CATransition *tr=[CATransition animation];
tr.duration=0.75;
tr.timingFunction=[CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionEaseInEaseOut];
tr.type=kCATransitionMoveIn;
tr.subtype=kCATransitionFromRight;
[vctr0.view.layer addAnimation:tr forKey:nil]; */
// actually here i want to remove vctr0 - viewcontroller 0 - a splash screen
// e.g [vctr0 removeFromSuperView];
// [window addSubView:tabBarObj];
// I don't know the correct code for this.
}

Thanks in advance for helping me.

A: 

Try

[vctr0.view removeFromSuperview];
Jongsma
Yes ! This also worked. But I wanted animation.
sugar
A: 

I had done some R & D on my code.

By the way, I got the solution as I wanted.

I implemented Following code & It was successful.

- (void)applicationDidFinishLaunching:(UIApplication *)application {    
tabBarObj = [[UITabBarController alloc] init];

vctr0=[[SplashScrn alloc] initWithNibName:@"SplashScrn" bundle:nil];
vctr1=[[SearchViewController alloc] initWithNibName:@"SearchViewController" bundle:nil];
vctr2=[[RootViewController alloc] initWithNibName:@"RootViewController" bundle:nil];

UINavigationController *nvctr1=[[[UINavigationController alloc]initWithRootViewController:vctr1] autorelease];
UINavigationController *nvctr2=[[[UINavigationController alloc]initWithRootViewController:vctr2] autorelease];

tabBarObj.viewControllers=[NSArray arrayWithObjects:nvctr1,nvctr2,nil];
[window addSubview:vctr0.view];
[window makeKeyAndVisible];

[NSTimer scheduledTimerWithTimeInterval:0.75 target:self selector:@selector(hideSplash) userInfo:nil repeats:NO];
}
-(void)hideSplash
{
CATransition *tr=[CATransition animation];
tr.duration=0.75;
tr.timingFunction=[CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionEaseInEaseOut];
tr.type=kCATransitionMoveIn;
tr.subtype=kCATransitionFromRight;
[tabBarObj.view.layer addAnimation:tr forKey:nil];
[window addSubview:tabBarObj.view];
}
sugar