如何将UITabBarController设置为View?

编程入门 行业动态 更新时间:2024-10-09 14:24:45
本文介绍了如何将UITabBarController设置为View?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我有一个有几个视图的应用。在一个视图中,我想添加一个 UITabBarController 。

I have an app that have several views. In one view I would like to add a UITabBarController.

在另一个应用程序中,我用它来添加 UITabBarController 到 rootViewController ,但我不确定这是否是正确的方法。

In another app I used this to add the UITabBarController to the rootViewController, but I am not sure if that is even the correct way to do it.

在.h

@property (nonatomic, retain) IBOutlet UITabBarController *tabBarController;

在.m

@synthesize tabBarController=_tabBarController; self.window.rootViewController = self.tabBarController;

推荐答案

在我的一个应用程序中,我使用了此代码在app之间设置tabbarcontroller

In one of my app i have used this code to set tabbarcontroller in between app

在AppDelegate.m中定义tabbar控制器

define tabbar controller in AppDelegate.m

self.tabBarController = [[UITabBarController alloc] init]; self.tabBarController.delegate=self; self.tabBarController.selectedIndex=0; self.tabBarController.delegate=self; - (BOOL)tabBarController:(UITabBarController *)tabBarController shouldSelectViewController:(UIViewController *)viewController{ //NSUInteger index=[[tabBarController viewControllers] indexOfObject:viewController]; // return YES; }

在下面的代码中应用你想用控制栏控制器推动你的控制器

Apply below code where you want to push your controller with tab bar controller

AppDelegate *delegate = (AppDelegate *)[[UIApplication sharedApplication] delegate]; UIViewController *viewController1 = [[GeneralViewController alloc] initWithNibName:@"GeneralViewController" bundle:nil]; UIViewController *viewController2 = [[MiscQuotationController alloc] initWithNibName:@"MiscQuotationController" bundle:nil]; UIViewController *viewController4 = [[QuotationListController alloc] initWithNibName:@"QuotationListController" bundle:nil]; UIViewController *viewController5 = [[ChargesViewController alloc] initWithNibName:@"ChargesViewController" bundle:nil]; UIViewController *viewController7 = [[SalesPartViewController alloc] initWithNibName:@"SalesPartViewController" bundle:nil]; /// tab button title viewController1.title = @"Basic information"; viewController2.title = @"Misc Quotation"; viewController4.title = @"Quotation Line"; viewController5.title = @"Charges"; viewController7.title = @"Sales Part Stock"; // tab button Images viewController1.tabBarItem.image = [UIImage imageNamed:@"general.png"]; viewController2.tabBarItem.image = [UIImage imageNamed:@"misle.png"]; viewController4.tabBarItem.image = [UIImage imageNamed:@"history.png"]; viewController5.tabBarItem.image = [UIImage imageNamed:@"charges.png"]; viewController7.tabBarItem.image = [UIImage imageNamed:@"shoebox.png"]; delegate.tabBarController = [[UITabBarController alloc] init]; delegate.tabBarController.selectedIndex = 0; delegate.tabBarController.viewControllers = [NSArray arrayWithObjects:viewController1, viewController2, viewController4, viewController5, viewController7, nil]; delegate.tabBarController.modalTransitionStyle = UIModalTransitionStyleCoverVertical; [self.navigationController pushViewController:delegate.tabBarController animated:YES];

更多推荐

如何将UITabBarController设置为View?

本文发布于:2023-11-25 21:44:07,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1631458.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:设置为   如何将   UITabBarController   View

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!