从iPhone窗口中删除viewController

时间:2009-08-27 23:18:19

标签: iphone uiviewcontroller

我的应用程序中有以下代码。

我的代码中的注释将指定“我的问题”。

- (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.
}

先谢谢你的帮助。

2 个答案:

答案 0 :(得分:1)

尝试

[vctr0.view removeFromSuperview];

答案 1 :(得分:0)

我做了一些R& D我的代码。

顺便说一句,我得到了我想要的解决方案。

我实施了以下代码&它很成功。

- (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];
}