我正在開發一個帶有標籤欄的ios應用程序。我在酒吧上有5個以上的按鈕,所以在iphone上我更多地使用了按鈕。 現在,假設我有這個按鈕:按鈕1按鈕2按鈕3按鈕4更多(和裏面更多)按鈕5按鈕6。 如果我點擊更多,然後Button5我進入相對於Button5的視圖。然後我點擊Button2(這不是更多),我進入相對於Button2的視圖。 目前爲止這麼好。 現在,如果我點擊更多,我不去更多選項卡,但回到相對於Button5的視圖。 我如何讓更多的按鈕始終走向更多的視野?我如何讓更多的按鈕始終更多的視圖?
回答
我用這個代碼在我的應用程序delegate.m解決問題
- (void)tabBarController:(UITabBarController *)tabBarController didSelectViewController:(UIViewController *)viewController {
UITabBarController* tabBarController2 = (UITabBarController*)self.window.rootViewController;
if (tabBarController2.selectedIndex < 4) {
[tabBarController2.moreNavigationController popViewControllerAnimated:NO];
}
}
你可以做的另一種方法是,無論何時用戶按下更多,第一個按鈕被刪除,其他按鈕被添加。 基本上,你可以創建一個數組,並保持其中的所有按鈕。然後基於按下的按鈕,您可以導航到特定的視圖。
對於防爆:
開始您有:Button1
Button2
Button3
Button4
Next
單擊下一步之後:Prev
Button3
Button4
Button5
Button6
很酷。我想,在目標C方面我並不那麼專業。 ^^' – 2013-03-27 10:11:37
你並不需要添加更多按鈕。只需設置視圖控制器到的UITabBarController
- (void)setViewControllers:(NSArray *)viewControllers animated:(BOOL)animated
,如果你有超過5個視圖控制器會自動創建一個更按鈕!即的NSArray的計數大於5
是的,我知道。問題在於如何點擊按鈕導致始終顯示第五個按鈕後面的按鈕鏈接的更多視圖,而不是顯示在更多視圖中選擇的最後一個視圖^^ – 2013-03-27 10:51:06
標籤欄顯示您的自定義的空間有限項目。如果將六個或更多自定義視圖控制器添加到選項卡欄控制器,則選項卡欄控制器僅顯示前四個項目加上標籤欄上的標準更多項目。點擊更多項目會彈出一個選擇剩餘項目的標準界面。標準更多項目的界面包含一個編輯按鈕,允許用戶重新配置標籤欄。 – 2013-03-27 11:05:22
我實際上沒有得到你想要的東西! 可能會闡述更多? – 2013-03-27 11:06:51
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
// Override point for customization after application launch.
UIViewController *viewController1 = [[UIViewController alloc] init];
UIViewController *viewController2 = [[UIViewController alloc] init];
UIViewController *viewController3 = [[UIViewController alloc] init];
UIViewController *viewController4 = [[UIViewController alloc] init];
UIViewController *viewController5 = [[UIViewController alloc] init];
UIViewController *viewController6 = [[UIViewController alloc] init];
UIViewController *viewController7 = [[UIViewController alloc] init];
UIViewController *viewController8 = [[UIViewController alloc] init];
UIViewController *viewController9 = [[UIViewController alloc] init];
[viewController1.view setBackgroundColor:[UIColor whiteColor]];
[viewController2.view setBackgroundColor:[UIColor redColor]];
[viewController3.view setBackgroundColor:[UIColor greenColor]];
[viewController4.view setBackgroundColor:[UIColor grayColor]];
[viewController5.view setBackgroundColor:[UIColor blueColor]];
[viewController6.view setBackgroundColor:[UIColor yellowColor]];
[viewController7.view setBackgroundColor:[UIColor brownColor]];
[viewController8.view setBackgroundColor:[UIColor magentaColor]];
[viewController9.view setBackgroundColor:[UIColor purpleColor]];
[viewController1 setTitle:@"one"];
[viewController2 setTitle:@"two"];
[viewController3 setTitle:@"three"];
[viewController4 setTitle:@"four"];
[viewController5 setTitle:@"five"];
[viewController6 setTitle:@"six"];
[viewController7 setTitle:@"seven"];
[viewController8 setTitle:@"eight"];
[viewController9 setTitle:@"nine"];
self.tabBarController = [[UITabBarController alloc] init];
self.tabBarController.viewControllers = @[viewController1, viewController2, viewController3, viewController4, viewController5, viewController6, viewController7, viewController8, viewController9];
self.window.rootViewController = self.tabBarController;
[self.window makeKeyAndVisible];
return YES;
}
我已經添加了我試圖和樣品的AppDelegate代碼其對我來說工作絕對好。讓我知道你在這有什麼問題。
我發現一個更簡單的解決方案,但這是真棒!非常感謝!對於像我這樣的新手這是純金! – 2013-03-29 10:28:41
- 1. 如何使UITabBarController的「更多」按鈕返回到根視圖
- 2. 如何讓更多的按鈕做工用HandleButtonAction和if語句
- 3. Android - 如何讓我的按鈕更改畫布上的圖形
- 4. 如何讓文本視圖比我的佈局中的按鈕佔用更多空間?
- 5. 如何讓圖像始終正視?
- 6. 文本視圖在點擊看更多的按鈕
- 7. 帶有「加載更多結果」按鈕的回收站視圖
- 8. 讓我的加載更多按鈕停止乘法並追加到我的列表視圖
- 9. 加載更多的按鈕,將加載更多的帖子
- 10. 如何爲我的博客創建「閱讀更多」按鈕?
- 11. 如何更改UITabBarController更多按鈕的標題?
- 12. 如何將ios「更多」按鈕的文本更改爲我的語言版本?
- 13. Ajax加載更多按鈕
- 14. 添加更多按鈕
- 15. jQuery加載更多按鈕
- 16. instagram加載更多按鈕
- 17. 如何在按鈕上方始終顯示PopupWindow(視圖)?
- 18. 如何將基礎按鈕更改爲始終啓用?
- 19. 如何使用swift更改多個按鈕上的多個圖像
- 20. 如何讓我的wifi始終打開?
- 21. Android:更改按鈕的父視圖
- 22. 視圖中的衆多按鈕
- 23. 如何讓此按鈕更新餘額?
- 24. 如何讓onclick();聽多個按鈕
- 25. Ruby/Tk:如何讓圖像獲得更小的按鈕部件
- 26. 如何更改另一個視圖中按鈕上的圖像
- 27. WordPress的「閱讀更多」按鈕
- 28. IOS:用的UILabel「顯示更多」按鈕
- 29. 的UITabBarController不顯示「更多」按鈕
- 30. 具有「更多」按鈕樣式的UIBarButtonItem
有沒有什麼辦法顯示在標籤欄中的所有六個按鈕,而不是顯示更多的按鈕,其中包含按鈕5和按鈕6 PLZ建議 – UserDeviOS 2013-12-27 11:48:30