2009-08-27 57 views
0

我在我的應用程序中有以下代碼。從窗口中刪除viewController iPhone

我的代碼中的評論將指定「我的問題」。

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

在此先感謝您的幫助。

回答

1

嘗試

[vctr0.view removeFromSuperview]; 
+0

是的!這也有效。但我想要動畫。 – 2009-08-27 23:23:29

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