ios 7.0 UINaviagtionController 和UITabbarController集成

lifer 发布于 2013/12/12 19:02
阅读 1K+
收藏 0

刚开始弄IOS7 ,把tabbarController 和navigationController集成之后,可视区域还是一个VIEW,并不是navigation 和tabbar 之间的距离。

//这个是mainControaller 继承了UITabbarController
-(void)initTabbarItem{

RecomViewController *recomVc=[[RecomViewController alloc]init];//此处存在xib文件,我在xib文件里面添加元素,navigation bar 始终占据头部,难道Navigation bar 不占据内容高度吗?

UINavigationController *renav=[[UINavigationController alloc]initWithRootViewController:recomVc]; renav.navigationBar.backgroundColor=[UIColor greenColor]; UIImage *reimg=[UIImage imageNamed:@"recomm_btn.png"] ; UITabBarItem *recomBar=[[UITabBarItem alloc]initWithTitle:@"推荐" image:reimg tag:1 ]; renav.tabBarItem=recomBar;

CameraViewController *cam=[[CameraViewController alloc]init];

UINavigationController *camnav=[[UINavigationController alloc]initWithRootViewController:cam]; camnav.navigationBar.tintColor=[UIColor purpleColor]; UIImage *camimg=[UIImage imageNamed:@"carmer_btn.png"] ; UITabBarItem *cambar=[[UITabBarItem alloc]initWithTitle:@"拍照" image:camimg tag:2 ]; camnav.tabBarItem=cambar; UserViewController *ucVC=[[UserViewController alloc]init]; UINavigationController *ucNav=[[UINavigationController alloc]initWithRootViewController:ucVC]; UIImage *ucimg=[UIImage imageNamed:@"my_btn.png"] ; UITabBarItem *ucbar=[[UITabBarItem alloc]initWithTitle:@"我的" image:ucimg tag:3 ]; ucNav.tabBarItem=ucbar; VotesViewController *votesVc=[[VotesViewController alloc]init]; UINavigationController *votesNav=[[UINavigationController alloc]initWithRootViewController:votesVc]; UIImage *voimg=[UIImage imageNamed:@"votes_btn.png"] ; UITabBarItem *voteBar=[[UITabBarItem alloc]initWithTitle:@"投票" image:voimg tag:4 ]; votesNav.tabBarItem=voteBar; MoreViewController *moreVc=[[MoreViewController alloc]init]; UINavigationController *moreNav=[[UINavigationController alloc]initWithRootViewController:moreVc]; UIImage *moreimg=[UIImage imageNamed:@"recomm_btn.png"] ; UITabBarItem *moreBar=[[UITabBarItem alloc]initWithTitle:@"更多" image:moreimg tag:5 ]; moreNav.tabBarItem=moreBar; NSArray *navControllers=@[renav,camnav,ucNav,votesNav,moreNav]; [self setViewControllers:navControllers animated:YES]; [self.tabBar setTintColor:[UIColor greenColor]]; } - (void)viewDidLoad { [super viewDidLoad]; // Do any additional setup after loading the view. [self initTabbarItem]; }



如图,我在xib文件里面添加元素,navigation bar 始终占据头部,难道Navigation bar 不占据内容高度吗?

加载中
0
amonxu
amonxu
你最后一句说对了,ios7中导航栏是不占高度的。你可以参考一下其它ios7应用是怎么设计的。
lifer
lifer
我看到有人设置了 EdgesForExtendedLayout:UIRectEdgeNone,就可以了
0
雨晨子龙
雨晨子龙

edgesForExtendedLayout属性是iOS7的特性,之前版本不可用。导航栏可以这么解决,但是标签栏好像不行的。

返回顶部
顶部