原址:http://www.cocoachina.com/bbs/read.php?tid=1476&toread=1&fpage=3&page=1
要做既有tabbar,还有nav bar,还要push的做法是不用tabbar controller,而是自己扔进去一个tabbar, 在appdelegate里control.
用NSNotificationCenter,需要隐藏的时候自己隐藏:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
|
[[ NSNotificationCenter defaultCenter] addObserver: self selector : @selector (hideTabBar) name:@ "hideTabBar" object: nil ];
[[ NSNotificationCenter defaultCenter] addObserver: self selector : @selector (showTabBar) name:@ "showTabBar" object: nil ];
-( void ) hideTabBar
{
[ self .tabBar setFrame:CGRectMake(0, 0, 0, 0)];
[ self .tabBar setHidden: YES ];
[ self .homeView sendSubviewToBack: self .tabBar];
}
-( void ) showTabBar
{
[ self .tabBar setFrame:CGRectMake(0, 431, 320, 49)];
[ self .tabBar setHidden: NO ];
[ self .homeView bringSubviewToFront: self .tabBar];
}
|
|
这样的话,push viewcontroller的时候就比较爽
1
2
3
4
5
6
7
|
- ( void )tableView:(UITableView *)tableView didSelectRowAtIndexPath:( NSIndexPath *)newIndexPath
{
mytestviewcontroller *testvc=[[mytestviewcontroller alloc] initWithNibName:@ "mytestviewcontroller" bundle: nil ];
[[ NSNotificationCenter defaultCenter] postNotificationName:@ "hideTabBar" object: nil ];
[ self .navigationController setNavigationBarHidden: YES animated: NO ];
[ self .navigationController pushViewController: testvc animated: YES ];
}
|
|
想不出还能有什么别的好办法……在tabbar里面套navbar,而且有时候要显示tabbar有时候又要全屏的情况下……