2013-06-26 92 views
0

我很抱歉提出两个类似的问题,但我不认为我第一次正确措词,我仍然努力寻找答案。切换到tabBarController,但没有标签栏

我在viewcontroller这是在一个项目中包含tabBarController。我想从viewController切换到tabbarcontroller中包含的某个视图控制器。问题是要么根本没有出现,要么我提出正常viewcontroller没有tab bar

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions 
{ 
    UIViewController *viewController1 = [[[FirstViewController alloc] initWithNibName:@"FirstViewController" bundle:nil] autorelease]; 
self.tabBarController.viewControllers = @[viewController1, viewController2,viewController3); 

} 

我想从我的标签视图控制器切换到FirstViewController

Tag.m 

-(IBAction)save:(id)sender{ 
FirstViewController*vc =[[FirstViewController alloc] initWithNibName:@"FirstViewController" bundle:nil]; 
[self.tabBarController.viewControllers popToViewController:vc animated:YES]; 

} 

更新:

我解决了这个加入我的ViewController我.m文件中的TabBar然后

[_tabBarController setSelectedIndex:0]; 
     [self presentViewController: _tabBarController animated:YES completion:NULL]; 

感谢我收到的回复是问题。

回答

1

你可以改变rootViewControllermainWindow的有些事情是这样的。

AppDelegate * appDel = (AppDelegate*)[[UIApplication sharedApplication] delegate]; 
[appDel.window setRootViewController:tabBarController]; 

享受..

+0

这是在应用程序didFinishLaunchingWithOptions:?我有self.window.rootViewController = self.tabBarController; –

+0

这就是你可以做到这一点。我已经写了这个答案使用任何地方在应用程序 –

+0

在tag.m它给我一个错误“未声明的标识符tabBarController”我也导入了appdelegate.h文件:/ –

相关问题