使用UITabBar而不使用UITabBarController创建项目 [英] Using UITabBar without creating a project with UITabBarController

查看:182
本文介绍了使用UITabBar而不使用UITabBarController创建项目的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想在我的项目中使用UITabBar。我没有创建一个基于uitabbar的项目。我想知道如何只有一个页面,我将能够使用UITabBar。我可以将它添加到页面,但我想添加它,并使用它在一个文件,而不是整个项目。我也想不重新启动这个项目,因为我有一个基于导航的项目模板被使用,并希望只是添加UITabBar到一个页面来回与两个视图。

I want to use a UITabBar in my project. I did not create a project that is uitabbar based. I was wondering how for only one page I would be able to use a UITabBar. I can add it to the page, but I would like to add it and use it on a file and not throughout the whole project. I would also like to not restart this project since I have a navigation based project template being used and would like to just add the UITabBar to a single page to go back and forth with two views.

我的项目的流程是Splash屏幕 - >登录页面 - > TableView - > TableView与搜索栏。我想在tableView的搜索栏做的是在底部有一个UITabBar,这将允许我在一个tableView到日历页之间,并保持搜索栏在顶部。我可以使用工具栏,但我认为tabbar看起来更好。

The flow of my project is Splash screen -> Login Page -> TableView -> TableView with search bar. What I want to do at the tableView with the search bar is to have a UITabBar at the bottom that will allow me to go between the one tableView to a calendar page and keep the search bar at the top. I could use a toolbar but I think the tabbar looks better.

任何帮助将非常感谢。

Any help would be much appreciated.

推荐答案

首先,只要你知道,就会违反 HIG

First of all, just so you know, you'll be violating the HIG:


标签栏显示在屏幕的底部边缘,应该可以从应用程序中的每个位置访问。

A tab bar appears at the bottom edge of the screen and should be accessible from every location in the application.

用户希望在其应用中使用标签栏进行最高级别的导航,因此在其他情况下使用它会造成混乱,我建议您

Users expect tab bars to be used for the highest-level navigation in their app, so using it in other situations is confusing, and I'd recommend that you go with a different UI paradigm.

说到这里,如果你的心设置这样做,很容易通过编程创建一个标签栏控制器:

Having said that, if your heart is set on doing this, it's easy to programatically create a tab bar controller:

UITabBarController *tabBarController = [[UITabBarController alloc] init];
[tabBarController setViewControllers:[NSArray arraywithObjects: firstViewController, secondViewController, nil] 
                            animated:NO];

并设置标签栏项:

firstViewController.tabBarItem = [UITabBarItem initWithTabBarSystemItem:UITabBarSystemItemFavorites tag:0];
secondViewController.tabBarItem = [UITabBarItem initWithTabBarSystemItem:UITabBarSystemItemFeatured tag:1];

然后只需做任何你需要做的事情 tabBarController :模态地显示它(颤抖),将它推到导航控制器(哦,上帝,人性),或任何。

Then just do whatever you need to do with tabBarController: present it modally (shudder), push it onto a navigation controller (oh god, the humanity), or whatever.

这篇关于使用UITabBar而不使用UITabBarController创建项目的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆