2009-08-27 2 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

Да! Это также сработало. Но мне нужна анимация. –

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]; 
} 
Смежные вопросы