2012-03-27 81 views
1

在委托类我写的代码如下显示标签栏从第二屏幕iphone

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:  (NSDictionary *)launchOptions 
{ 

[self generateFirstScreen]; 
[self removeFirstScreen]; // On login check implement this method or u can directly   write the snippet here as well. 
[self prepareControllersOnTabs]; //your tab controller code function 
[self.window makeKeyAndVisible]; 
return YES; 
} 
-(void) removeFirstScreen 
{ 
[firstScreen removeFromSuperView]; 
self.window.rootViewController = self.tabBarController; 
[firstScreen release]; 
} 
-(void) generateFirstScreen 
{ 
FirstScreen *firstScreen = [[FirstScreen alloc]init]; 
[self.navigationController pushViewController:firstScreen animated:YES]; 
[firstScreen release]; 
} 

但generateFirstScreen工作正常,但removeFirstScreen给出了一个例外,请帮帮我。

+1

什么是你的实际需求.. – Narayana 2012-03-27 10:01:08

+0

我的实际需要是第一屏出标签栏的控制和从第二个屏幕开始标签栏会提前 – Venkat 2012-03-27 10:25:45

+0

来.Thanks来此聊天室http://chat.stackoverflow.com/rooms/8469/room-for-and-ra-pradesh-mobile-developers – Narayana 2012-03-27 10:26:51

回答

1

指定例外...

没有addSubview你怎么从超级删除它。你想使用popViewController吗?

再一次,你只分配firstScreen一次&释放它两次..!

+0

NsInvalidArgument异常 – Venkat 2012-03-27 10:26:02

+0

其中我需要为addSubView编写代码请告诉我 – Venkat 2012-03-27 10:28:33

+0

由于BobDev表示只有添加它才能删除视图。如果你想删除你已经推送到UINavigationController的firstScreen,那么你必须使用popViewController。所以我不建议你在代码 – 2012-03-27 10:33:26

1

如果您不确定它是否被添加到视图中,请不要删除屏幕,否则您会崩溃..您可以为此视图指定标记并检查主视图的子视图以检查您的视图在某处有..

0
your generateFirstScreen method Change like below 
FirstScreen *firstScreen = [[FirstScreen alloc]initWithNibName:@"FirstScreen" bundle:nil]; 
navigationController = [[UINavigationController alloc] initWithRootViewController:self.objLogin]; 
     // Add the navigation controller's view to the window and display. 
[self.window addSubview:navigationController.view]; 
[self.window makeKeyAndVisible]; 

//call this metod when ever u want tabbar 
-(void)tabBarControllerView 
{ [self.navigationController.view removeFromSuperview]; 
    [self.navigationController.view setHidden:YES] ; 
    self.tabBarController.selectedIndex = 0; 
    self.tabBarController.view.hidden=NO; 
    [window addSubview:self.tabBarController.view]; 
}