使用标签栏项目加载视图!

发布于 2024-10-04 10:37:34 字数 339 浏览 0 评论 0原文

是否可以借助选项卡栏项目来显示视图。让我清楚地向您解释这个问题。我创建了基于视图的应用程序。添加了两个视图让我们说第一和第二。第一个视图包含一个按钮,可将我们带到第二个视图。第二个视图还包含一个按钮,可将我们带到第三个视图。我已将选项卡栏添加到第三个视图,并向其中添加了四个选项卡栏项目。现在我想将选项卡栏项目链接到视图。让我们说第四、第五和第六。

第一个视图(按钮)->第二个视图(按钮)-->第三个视图(包含选项卡栏和 4 个选项卡栏项目)。但所有项目都有空视图。当我选择选项卡栏项目时,我必须加载我创建的 .xib 文件。如何将选项卡栏项目与视图控制器链接,以便我可以加载视图。另外,还有其他选项可以加载带有选项卡栏项目的视图吗?

is that possible to bring the view with the help of tab bar item. let me explain you the question clearly.I created view based application. Added two vies let us say first and second. the first view contains a button that takes us to the second view. Second view also contains a button that takes us to the third view. I have added tab bar to the third view and added four tab bar items to it. Now I want to link the tab bar items to the views. Let us say 4th , 5th and sixth.

1st View(Buton) -> 2nd View(button)-->third view (contains tab bar and 4 tab bar items). But all the items have empty views. When I select the tab bar item i have to load .xib files i created. How to link a tab bar item with a view controller so that i can load views. Else , is there any other options to load the views with tab bar items??

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

花心好男孩 2024-10-11 10:37:34

如果您的意思是如何将视图加载到选项卡栏控制器中,请执行以下操作:

UITabBarController *tabView = [[UITabBarController alloc] init];
UIViewController *view4 = [[UIViewController alloc] init];
UITabBarItem *view4TabBarItem = [[UITabBarItem alloc] initWithTitle:@"4" image:[UIImage imageNamed:@"icon4.png"] tag:nil];
view4.tabBarItem = view4TabBarItem;
[view4TabBarItem release];
UIViewController *view5 = [[UIViewController alloc] init];
UITabBarItem *view5TabBarItem = [[UITabBarItem alloc] initWithTitle:@"5" image:[UIImage imageNamed:@"icon5.png"] tag:nil];
view5.tabBarItem = view5TabBarItem;
[view5TabBarItem release];
UIViewController *view6 = [[UIViewController alloc] init];
UITabBarItem *view6TabBarItem = [[UITabBarItem alloc] initWithTitle:@"6" image:[UIImage imageNamed:@"icon6.png"] tag:nil];
view6.tabBarItem = view6TabBarItem;
[view6TabBarItem release];
NSArray *viewControllers = [[NSArray alloc] initWithObjects:view4,view5,view6,nil];
[view4 release];
[view5 release];
[view6 release];
tabView.viewControllers = viewControllers;
[viewControllers release];
[self presentModalViewController:tabView animated:YES];
[tabView release];

If you mean how do you load the views into a tab bar controller then do something like this:

UITabBarController *tabView = [[UITabBarController alloc] init];
UIViewController *view4 = [[UIViewController alloc] init];
UITabBarItem *view4TabBarItem = [[UITabBarItem alloc] initWithTitle:@"4" image:[UIImage imageNamed:@"icon4.png"] tag:nil];
view4.tabBarItem = view4TabBarItem;
[view4TabBarItem release];
UIViewController *view5 = [[UIViewController alloc] init];
UITabBarItem *view5TabBarItem = [[UITabBarItem alloc] initWithTitle:@"5" image:[UIImage imageNamed:@"icon5.png"] tag:nil];
view5.tabBarItem = view5TabBarItem;
[view5TabBarItem release];
UIViewController *view6 = [[UIViewController alloc] init];
UITabBarItem *view6TabBarItem = [[UITabBarItem alloc] initWithTitle:@"6" image:[UIImage imageNamed:@"icon6.png"] tag:nil];
view6.tabBarItem = view6TabBarItem;
[view6TabBarItem release];
NSArray *viewControllers = [[NSArray alloc] initWithObjects:view4,view5,view6,nil];
[view4 release];
[view5 release];
[view6 release];
tabView.viewControllers = viewControllers;
[viewControllers release];
[self presentModalViewController:tabView animated:YES];
[tabView release];
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文