分享

ios 7.0 UINaviagtionController 和UITabbarController集成

 没原创_去搜索 2015-08-10

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

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
//这个是mainControaller 继承了UITabbarController
-(void)initTabbarItem{
<p>
    RecomViewController *recomVc=[[RecomViewController alloc]init];<span style="font-family:'Courier New', Arial;font-size:12px;line-height:18px;background-color:#F6F6F6;">//此处存在xib文件,我在xib文件里面添加元素,navigation bar 始终占据头部,难道Navigation bar 不占据内容高度吗?</span>
</p>
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;
<p>
    CameraViewController *cam=[[CameraViewController alloc]init];
</p>
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 不占据内容高度吗? 

liferlifer
发帖于 2年前
2回/1099阅

按票数排序  显示最新答案  共有2个答案 (最后回答: 5个月前 )

    0
  • 魏武帝
    你最后一句说对了,ios7中导航栏是不占高度的。你可以参考一下其它ios7应用是怎么设计的。
    --- 共有 1 条评论 --- 
    • lifer我看到有人设置了 EdgesForExtendedLayout:UIRectEdgeNone,就可以了(2年前)  
    评论(1)引用此答案|  举报 (2013-12-12 19:37)
  • 0
  • 雨晨子龙

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


    本站是提供个人知识管理的网络存储空间,所有内容均由用户发布,不代表本站观点。请注意甄别内容中的联系方式、诱导购买等信息,谨防诈骗。如发现有害或侵权内容,请点击一键举报。
    转藏 分享 献花(0

    0条评论

    发表

    请遵守用户 评论公约

    类似文章 更多