-1

私はUIViewControllerからサインインした後でUITabBarControllerを呼び出したいNavigationControllerを使用しないで、あるビューから別のビューにナビゲートする方法はありますか?

私はpushViewControllerを使用しますが、動作しません。 ここに私のコードは

let dashboarController = DashboardTabBarController() 
    self.navigationController?.pushViewController(dashboarController, animated: false) 
    self.dismiss(animated: true, completion: nil) 

これは私がiOSの開発の初心者だDashboardController

DashboardTabBarController: UITabBarController, UITabBarControllerDelegate { 

override func viewDidLoad() { 
    super.viewDidLoad() 
    self.delegate = self 
    self.view.backgroundColor = UIColor.white 

    print("test") 
    // Do any additional setup after loading the view. 
} 

override func viewWillAppear(_ animated: Bool) { 
    super.viewWillAppear(animated) 

    let tabOne = MerchantTableViewController() 
    let tabOneBarItem = UITabBarItem(title: "Merchant", image: UIImage(named: "icon_merchant"), selectedImage: UIImage(named: "icon_merchant")) 
    tabOne.tabBarItem = tabOneBarItem 

    let tabTwo = RewardsViewController() 
    let tabTwoBarItem2 = UITabBarItem(title: "Rewards", image: UIImage(named: "icon_reward"), selectedImage: UIImage(named: "icon_reward")) 
    tabTwo.tabBarItem = tabTwoBarItem2 

    let tabThree = ViewController() 
    let tabTwoBarItem3 = UITabBarItem(title: "Promos", image: UIImage(named: "icon_promos"), selectedImage: UIImage(named: "icon_promos")) 
    tabThree.tabBarItem = tabTwoBarItem3 

    let tabFour = MerchantTableViewController() 
    let tabTwoBarItem4 = UITabBarItem(title: "Transactions", image: UIImage(named: "icon_card"), selectedImage: UIImage(named: "icon_card")) 
    tabFour.tabBarItem = tabTwoBarItem4 

    let tabFive = ProfileViewController() 
    let tabTwoBarItem5 = UITabBarItem(title: "Profile", image: UIImage(named: "icon_profile"), selectedImage: UIImage(named: "icon_profile")) 
    tabFive.tabBarItem = tabTwoBarItem5 
    self.viewControllers = [tabOne, tabTwo, tabThree, tabFour, tabFive] 

    } 
} 

で私のコードです。ありがとう

答えて

0

Apple doc says :ナビゲーションコントローラオブジェクトは、表示コントローラの配列で表されるナビゲーションスタックを使用して、現在表示されている画面を管理します。配列内の最初のビューコントローラはルートビューコントローラです。アレイ内の最後のビューコントローラは、現在表示されているビューコントローラです。です。 seguesを使用して、またはこのクラスのメソッドを使用して、スタックからView Controllerを追加および削除します。

だから今、あなたはあなたにたかっていない場合UINavigationControllerを使用し、メソッドの下に続く、UIViewControllerを追加します。

  1. Present ViewController
  2. Add as a Child VC
0
  • ビューを持っている必要がありますナビゲートしているコントローラはナビゲーションにあります。そうでない場合は、ルートビューコントローラとしてソースビューコントローラを持つルートでナビゲーションビューコントローラのオブジェクトを作成します。

ナビゲーションコントローラを使用しない場合は、PresentViewControllerメソッドを使用してビューコントローラを表示できます。

関連する問題