2010-02-22 52 views
1

我是iphone开发新手。我创建了一个基于视图的应用程序。现在我想在该视图中的标签栏。标签栏的第一个视图是一个表视图,第二个视图是Web视图。所有教程只解释基于标签栏的应用程序。因为我使用基于视图的应用程序,我发现它真的很难。如何使用接口构建器来实现它。请指导我。任何示例教程将更加有用。请帮助我。谢谢。基于视图的应用程序中的选项卡栏?

+0

你可以重新启动它作为“标签栏应用程序”吗? – kennytm 2010-02-22 12:22:29

+0

这是一个重复的http://stackoverflow.com/questions/2326814/how-to-add-tabbarcontroller-in-viewcontroller-in-iphone/ – 2010-03-03 19:16:34

+0

@ Kristopher ..我问这个问题9天前,和pugal问他的问题7天后,我可以如何复制它? – Warrior 2010-03-03 19:23:43

回答

4

试试这个。此代码以编程方式创建标签栏应用程序。所以点击按钮就会打开视图中的标签栏。

-(IBAction) clkBtn:(id) sender 
    { 

    UITabBarController *tabbar1 = [[UITabBarController alloc] init]; 

    firstViewController *first = [[firstViewController alloc] initWithNibName:@"firstViewController" bundle:nil]; 

    UINavigationController *tabItem1 = [[[UINavigationController alloc] initWithRootViewController: first] autorelease]; 

    secondViewController *second = [[secondViewController alloc] initWithNibName:@"secondViewController" bundle:nil]; 

    UINavigationController *tabItem2 = [[[UINavigationController alloc] initWithRootViewController: second] autorelease]; 

    tabbar1.viewControllers = [NSArray arrayWithObjects:tabItem1, tabItem2,nil]; 

    [self.view insertSubview:tabbar1.view belowSubview: first.view]; 

    [self presentModalViewController:tabbar1 animated:YES]; 

    } 

感谢,

好运。

+0

这是否适用于推视图控制器? – Warrior 2010-06-09 14:56:57

+0

@战士。是的,因为在视图中添加了导航控制器。所以它推动了这个观点。 – Pugal 2010-06-09 15:13:18

+0

Thanks.It是一个非常好的答案 – Warrior 2010-06-09 15:17:06

相关问题