簡體   English   中英

以編程方式更改UITabBar選擇的視圖

[英]Change UITabBar selected view programmatically

我正在嘗試以編程方式更新我的UITabBar選擇的視圖,我嘗試了以下代碼:

UIViewController *currentView = self.frostedViewController.contentViewController;
NSLog(@"Current Index %lu", currentView.tabBarController.selectedIndex);
currentView.tabBarController.selectedIndex = 3;
NSLog(@"changing index %lu", currentView.tabBarController.selectedIndex);

//self.frostedViewController.contentViewController = categorie;
[self.frostedViewController hideMenuViewController];

但是選項卡欄視圖沒有改變檢查此圖像: 在此處輸入圖片說明

通過設置selectedViewController:

func selectTab(atIndex index: Int) {
    if index >= 0 && index < tabBarController.viewControllers.count {
       tabBarController.selectedViewController = tabBarController.viewControllers[index]
    }
}

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM