点击 UITabbarController 子页面的按钮时,如何用 push 类型跳转到新的 DetailVIewController - V2EX
V2EX = way to explore
V2EX 是一个关于分享和探索的地方
现在注册
已注册用户请  登录
iOS 开发实用技术导航
NSHipster 中文版
http://nshipster.cn/
cocos2d 开源 2D 游戏引擎
http://www.cocos2d-iphone.org/
CocoaPods
http://cocoapods.org/
Google Analytics for Mobile 统计解决方案
http://code.google.com/mobile/analytics/
WWDC
https://developer.apple.com/wwdc/
Design Guides and Resources
https://developer.apple.com/design/
Transcripts of WWDC sessions
http://asciiwwdc.com
Cocoa with Love
http://cocoawithlove.com/
Cocoa Dev Central
http://cocoadevcentral.com/
NSHipster
http://nshipster.com/
Style Guides
Google Objective-C Style Guide
NYTimes Objective-C Style Guide
Useful Tools and Services
Charles Web Debugging Proxy
Smore
pysama
V2EX    iDev

点击 UITabbarController 子页面的按钮时,如何用 push 类型跳转到新的 DetailVIewController

  •  
  •   pysama 2015-05-20 16:35:50 +08:00 4209 次点击
    这是一个创建于 3802 天前的主题,其中的信息可能已经有所发展或是发生改变。

    最开始的做法:使用segue将UITabbarController子页面的按钮和DetailVIewController连接起来,此时类型只能选择modal风格或其他,一旦我选择push风格,build时就会报错“push只能应用在navigatorController中”。

    我继续尝试过:将一组UINavigator页面(一个RootViewController和一个DetailViewController)嵌入到UITabItem,功能确实实现了,但是不完美,跳转到DetailViewController时,应用底部的tabbar一直存在。我要的效果是,在页面跳转的时候,tabbar也一起被push到左侧去。就好像整个UITabbarController的内容都被push到左侧隐藏了。

    希望得到大家的帮助,谢谢!

    6 条回复    2015-05-20 21:28:47 +08:00
    black
        1
    black  
       2015-05-20 16:46:03 +08:00
    DetailViewController *detail = ...;
    detail.hidesBottomBarWhenPushed = YES;
    self.navigationController push...

    懂了吗?
    black
        2
    black  
       2015-05-20 17:04:01 +08:00   1
    UITabBarController 嵌入一组 UINavigationController (每个 tab 对应一个) 是很典型的 UI 结构,hidesBottomBarWhenPushed 属性也正是为了满足楼主你这种普遍需求设计的。
    pysama
        3
    pysama  
    OP
       2015-05-20 17:23:03 +08:00
    @black 你的答案直观明了,晚上回家再试试
    非常感谢哈。
    plutodai
        4
    plutodai  
       2015-05-20 17:29:26 +08:00
    如果不想push的时候tabbar也被push到左侧去的话,你可以这么做:

    将RootViewConroller嵌入到UINavigationController中
    RootViewConroller *rootVC = [[RootViewConroller alloc] init];
    UINavigationController *rootNaVC = [[UINavigationController alloc] initWithRootViewController:rootVC];
    UITabbarController *tabbarC = [[UITabbarController alloc] init];
    [tabbarC setViewControllers:@[rootNaVC]];
    self.window.rootViewCOnntroller= tabbarC;
    pysama
        5
    pysama  
    OP
       2015-05-20 21:27:48 +08:00
    弄好了,真棒~
    顺便优化下,在rootVC的页面不显示navBar

    - (void)viewWillAppear:(BOOL)animated
    {
    [self.navigationController setNavigationBarHidden:YES animated:animated];
    }

    -(void)viewWillDisappear:(BOOL)animated
    {
    [self.navigationController setNavigationBarHidden:NO animated:animated];
    }
    pysama
        6
    pysama  
    OP
       2015-05-20 21:28:47 +08:00
    @plutodai 我做的demo中,默认情况就是:tabbar不会被push到左侧去呢。
    还是感谢哈~
    关于     帮助文档     自助推广系统     博客     API     FAQ     Solana     899 人在线   最高记录 6679       Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 26ms UTC 20:14 PVG 04:14 LAX 13:14 JFK 16:14
    Do have faith in what you're doing.
    ubao msn snddm index pchome yahoo rakuten mypaper meadowduck bidyahoo youbao zxmzxm asda bnvcg cvbfg dfscv mmhjk xxddc yybgb zznbn ccubao uaitu acv GXCV ET GDG YH FG BCVB FJFH CBRE CBC GDG ET54 WRWR RWER WREW WRWER RWER SDG EW SF DSFSF fbbs ubao fhd dfg ewr dg df ewwr ewwr et ruyut utut dfg fgd gdfgt etg dfgt dfgd ert4 gd fgg wr 235 wer3 we vsdf sdf gdf ert xcv sdf rwer hfd dfg cvb rwf afb dfh jgh bmn lgh rty gfds cxv xcv xcs vdas fdf fgd cv sdf tert sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf shasha9178 shasha9178 shasha9178 shasha9178 shasha9178 liflif2 liflif2 liflif2 liflif2 liflif2 liblib3 liblib3 liblib3 liblib3 liblib3 zhazha444 zhazha444 zhazha444 zhazha444 zhazha444 dende5 dende denden denden2 denden21 fenfen9 fenf619 fen619 fenfe9 fe619 sdf sdf sdf sdf sdf zhazh90 zhazh0 zhaa50 zha90 zh590 zho zhoz zhozh zhozho zhozho2 lislis lls95 lili95 lils5 liss9 sdf0ty987 sdft876 sdft9876 sdf09876 sd0t9876 sdf0ty98 sdf0976 sdf0ty986 sdf0ty96 sdf0t76 sdf0876 df0ty98 sf0t876 sd0ty76 sdy76 sdf76 sdf0t76 sdf0ty9 sdf0ty98 sdf0ty987 sdf0ty98 sdf6676 sdf876 sd876 sd876 sdf6 sdf6 sdf9876 sdf0t sdf06 sdf0ty9776 sdf0ty9776 sdf0ty76 sdf8876 sdf0t sd6 sdf06 s688876 sd688 sdf86