Re: [問題] navigation + tabbar
※ 引述《issuemylove (skill)》之銘言:
: 各位大大好
: 想請問 navigation + tabbar 的情況下
: 我想要 navigation bar 上增加 subview
: 我看範例是在 tab item 對應的 view controller 上寫下
: self.tabBarController.navigationController.navigation addSubView: myView];
: 即可增加 subview
: 可是我怎樣都試不出來呀QQ...
: 一直都沒有 view 產生 也沒 error message
: 還是我有甚麼先決條件沒看到嗎?
: 謝謝!
tabBarController跟navigationController結合的方式有兩種,
第一種是以UITabBarController控管UINavigationController:
UIViewController設定為UINavigationController的rootViewController,
然後以NSArray包裝數個UINavigationController後,
再用[tabBarController setViewControllers:array animated:animatedOrNot],
這樣的方式結合。
如此狀況下想要在navigationBar上面新增物件,
那麼就在當前的UIViewController下:
self.navigationItem
或是
self.navigationController.navigationBar
就可以操作到當前畫面上的navigationBar了。
第二種是以UINavigationController控管UITabBarController:
以NSArray包裝數個UIViewController後,
再用[tabBarController setViewControllers:array animated:animatedOrNot],
然後再將tabBarController設定為navigationController的rootViewController。
這樣的情況下,
self.tabBarController.navigationItem
或是
self.tabBarController.navigationController.navigationBar
應該可以操作到當前畫面上的navigationBar。
另外,你也可以檢查你要顯示的navigationController是不是你要的那ㄧ個。
我會在我想像中的那個navigationController在alloc init之後,
用
NSLog(@"navigationController[%p] allocated and init", navigationController);
去印出這個navigationController的指標位置,
然後再到你取用這個navigationController的地方,
NSLog(@"navigationController[%p]", self.xxxxxx.navigationController);
去印出這個navigationController的指標位置,並比對兩者是否相同。
「xxxxxx」根據你建立navigationController的結構(如上面兩種所述)會有不同。
以上供您參考。
--
※ 發信站: 批踢踢實業坊(ptt.cc)
◆ From: 220.133.47.18
推
10/01 11:02, , 1F
10/01 11:02, 1F
推
10/01 11:41, , 2F
10/01 11:41, 2F
推
10/01 11:49, , 3F
10/01 11:49, 3F
推
10/02 18:26, , 4F
10/02 18:26, 4F
→
10/04 11:00, , 5F
10/04 11:00, 5F
→
10/04 11:01, , 6F
10/04 11:01, 6F
→
10/04 11:02, , 7F
10/04 11:02, 7F
→
10/04 11:03, , 8F
10/04 11:03, 8F
→
10/04 11:04, , 9F
10/04 11:04, 9F
→
10/04 11:05, , 10F
10/04 11:05, 10F
→
10/04 11:06, , 11F
10/04 11:06, 11F
→
10/04 11:06, , 12F
10/04 11:06, 12F
討論串 (同標題文章)
本文引述了以下文章的的內容:
完整討論串 (本文為第 2 之 2 篇):