1
A
回答
0
你可以做的是將一個UIToolBar到你的故事板控制器和設置按鈕,你想在那裏的行動。你可以讓所有的控制器擴展成相同的基類,不必重複你的代碼,也可以在代碼中實例化這個工具欄,如果你覺得它更令人愉快。
問題將在於使用導航,因爲導航欄將替換/重疊此工具欄。
UIToolbar *myToolbar = [[UIToolbar alloc] initWithFrame:CGRectMake(0, 0, self.view.bounds.size.width, 44)];
UIBarButtonItem *myButton = [[UIBarButtonItem alloc] initWithTitle:@"Title"
style:UIBarButtonItemStyleBordered
target:self
action:@selector(myAction:)];
[myToolbar setItems:[NSArray arrayWithObjects:myButton, nil]];
[self.view addSubview:myToolbar];
0
在AppDidFinishLaunching:
Add Your TabBarcontroller (rootViewController) for UINavigationController
現在添加下面的設置按鈕例子的導航欄
UIBarButtonItem *rightButton = [[UIBarButtonItem alloc] initWithTitle:@"Done"
style:UIBarButtonSystemItemDone target:nil action:nil];
navigationCOntroller.navigationItem.rightBarButtonItem = rightButton
rightButton將是可見的throught應用
0
如果你只是想放置帶有設置按鈕的導航欄,可以使用U從任何視圖進行訪問ITabBarController你可以在AppDelegate中做這樣的事情 - >
YourViewController1 *yourVC1 = [YourViewController1 alloc] initWithNibName:@"YourViewController1" bundle:nil];
UINavigationController *yourNVC1 = [[UINavigationController alloc] initWithRootViewController:yourVC1];
YourViewController2 *yourVC2 = [YourViewController2 alloc] initWithNibName:@"YourViewController2" bundle:nil];
UINavigationController *yourNVC2 = [[UINavigationController alloc] initWithRootViewController:yourVC2];
UITabBarController *tabBC = [[UITabBarController alloc] init];
[tabBC setViewControllers:[NSArray arrayWithObjects:yourNVC1, yourNVC2, nil]];
self.window.rootViewController = tabBC;
你應該在所有視圖上都有一個帶有導航欄的標籤欄。現在,將設置按鈕放置在導航欄中,將其添加到您想要顯示設置按鈕的視圖控制器中的viewDidLoad方法 - >
UIBarButtonItem *selectBarButton = [[UIBarButtonItem alloc] initWithTitle:@"Settings" style:UIBarButtonItemStyleBordered target:self action:@selector(selectorName:)];
self.navigationItem.rightBarButtonItem = selectBarButton;
相關問題
- 1. 導航欄停留在右邊
- 2. 強制導航欄元素停留在一條線上
- 3. 懸停效果留在Bootstrap導航欄上
- 4. 更改tabbarcontroller的導航欄backgroundcolor
- 5. 導航欄在導航欄上搜索
- 6. 在tabbarcontroller內的所有導航欄上的持久UIBarButtonItem
- 7. 導航欄懸停
- 8. MPMoviePlayer留下空間上方導航欄
- 9. tabBarController導航問題/
- 10. 導航/ TabBarController消失
- 11. 導航欄上的導航欄
- 12. 導航欄上方的導航欄
- 13. 導航欄上方的導航欄
- 14. 導航欄上懸停下拉
- 15. Bootstrap導航欄停留在路線更改
- 16. 導航欄不會停留在網頁的一側
- 17. 導航欄不會停留在頁面頂部的水平線
- 18. 導航欄懸停下拉
- 19. 圖像導航欄懸停
- 20. 導航欄不會留在Bootstrap站點
- 21. 將留在導航欄右側的UIBarButtonItem
- 22. 導航欄不停留在標題上的初始油漆,但罰款刷新?
- 23. 導航不停留在滑塊底部
- 24. 在導航欄停留和標籤欄消失的情況下執行segue
- 25. inline-block在導航欄上
- 26. TabBarController + TableViewController +導航控制器?
- 27. 帶導航條的TabBarController
- 28. Tabbarcontroller與導航控制器
- 29. jQuery的懸停在導航欄李
- 30. 將CSS懸停在導航欄中
我不需要使用導航。我只是想要一個地方放置設置按鈕,看起來不錯,可以從任何選項卡訪問。 –
那麼在這種情況下,我提出的解決方案將不會出現問題,請嘗試一下並讓我知道。 – 8vius
我用一小段代碼編輯了我的答案,只需在界面構建器中完成相同的操作,然後用控制拖拽 – 8vius