作者psheaven (呗咩)
看板MacDev
标题[问题] Tabbar的切换问题
时间Wed May 28 16:06:59 2014
各位好,初学不久想请教关於TabBar的问题,不使用storyboard建立,都用独立Xib来做
先建立了4个页面,1个是UITabbarController,3个是UIViewController
在AppDelegate内先写code
将UIViewController都用UINavigationController包起来,想要让每一页都能有导航列
执行後三个BarItem能正常切换页面
接着想要在page2的部份做成,点下tablerow即可用navigation push到下一个tabbar
这边有两个page的Tabbar,也都用NavigationController包着
如附图...
http://ppt.cc/eGII
跑出来的样子如右下,背景全黑,且一进去切换到的页面是在第二页><
也没有出现能回到上一页的导航列...
请各位前辈帮帮忙,感激不尽~~~~
附上点击TableRow的这段code
---------------
- (void)tableView:(UITableView *)tableView
didSelectRowAtIndexPath:(NSIndexPath *)indexPath{
TBTView2_1* vc1 = [TBTView2_1 new];
UINavigationController* nvc1 = [[UINavigationController
alloc]initWithRootViewController:vc1];
TBTView2_2* vc2 = [TBTView2_2 new];
UINavigationController* nvc2 = [[UINavigationController
alloc]initWithRootViewController:vc2];
vc1.title = @"VC2-1";
vc2.title = @"VC2-2";
nvc1.title = @"NVC 2-1";
nvc2.title = @"NVC 2-2";
self.tabBarController.viewControllers = [NSArray arrayWithObjects:nvc1,
nvc2, nil];
[self.navigationController pushViewController:self.tabBarController
animated:YES];
}
我的想法是用原本建立的TabBarController作修改,然後push过去...
可是失败了Orz
--
※ 发信站: 批踢踢实业坊(ptt.cc), 来自: 125.227.149.174
※ 文章网址: http://webptt.com/cn.aspx?n=bbs/MacDev/M.1401264422.A.543.html
1F:推 tentenlee:log不是写很清楚 你没有view呀... 单然都黑的 05/28 16:22
2F:→ darktt:你要多建立一个新的TabViewController,不能使用原本的 05/28 16:53
3F:→ darktt:原本的TabBar就将它藏起来就好 05/28 16:54
刚多加了一个新的tabBarController,隐藏原本的
接着push过去就出现了导航列~也没有nil view的log讯息了,感谢!!!
但画面还是黑的QQ
4F:→ darktt:我按照你的作法做了一个相同的专案,你看看中间的差异吧 05/28 18:59
谢谢你!!!我会好好研究一下的 Q____O
※ 编辑: psheaven (122.116.165.112), 05/28/2014 20:52:50