2015-09-09 20 views
0

我想從UIViewController回到UITableViewControllerUITableViewControllerUITabBarController的子視圖。我爲它寫了下面的代碼。但是UITabBarController不加載。我搜索並找到了answer,但是當我通過鏈接移動時,我看到找不到頁面。它如何編程?請幫幫我。如何在從Nib文件移動後顯示UITabBarController

@IBAction func backPlaylistTable(sender: UIBarButtonItem) { 
     if boolForSong == true { 
      let storyboard = UIStoryboard(name: "Main", bundle: NSBundle.mainBundle()) 
      let playlistTable = storyboard.instantiateViewControllerWithIdentifier("playlistNavi") as! UINavigationController 
      presentViewController(playlistTable, animated: true, completion: nil) 
     } 
    } 

UITableViewController具有下面的代碼

override func viewDidAppear(animated: Bool) { 
     super.viewDidAppear(animated) 
     self.tabBarController?.tabBar.hidden = false 
     self.tableView.reloadData() 
    } 

UPDATEUITabBarController。我更新了它。我想從第三個UIViewController移動到第三個UITableViewController,但是當我做到這一點時,UITabBarController不會加載。

enter image description here

不過我試了一下,但是當我從UIViewConroller移動的UITabBarController打開第一UITabBarController但我想UITabBarController打開第三UITableViewController

@IBAction func thirdPlaylist(sender: UIButton) { 
     let storyboard = UIStoryboard(name: "Main", bundle: NSBundle.mainBundle()) 
     let passToTaBBarController = storyboard.instantiateViewControllerWithIdentifier("mainTabBarController") as! UITabBarController 
     let playListTVC = storyboard.instantiateViewControllerWithIdentifier("playlistTVCStoryboard") as! UITableViewController 
     passToTaBBarController.selectedViewController?.presentViewController(playListTVC, animated: true, completion: nil) 
     presentViewController(passToTaBBarController, animated: true, completion: nil) 
    } 
+0

你有沒有UITabBarController作爲你的UINavigationController的rootViewController? – pixyzehn

+0

UITabBarController是rootViewController – Alexander

回答

0

我解決了它。我改變了我的代碼,它適用於我。我做了UITabBarController將按索引選擇UITableViewController

@IBAction func thirdPlaylist(sender: UIButton) { 
     let storyboard = UIStoryboard(name: "Main", bundle: NSBundle.mainBundle()) 
     let passToTaBBarController = storyboard.instantiateViewControllerWithIdentifier("mainTabBarController") as! UITabBarController 
     passToTaBBarController.selectedIndex = 2 
     presentViewController(passToTaBBarController, animated: true, completion: nil) 
    } 
0

你需要加載的UITabBarController
變化代碼如下:

@IBAction func backPlaylistTable(sender: UIBarButtonItem) { 
    if boolForSong == true { 
     let storyboard = UIStoryboard(name: "Main", bundle: NSBundle.mainBundle()) 
     let tabCro = storyboard.instantiateViewControllerWithIdentifier("you tab cro id") as! UITabBarController 
     presentViewController(tabCro, animated: true, completion: nil) 
    } 
} 
+0

UITabBarController有三個UITableViewController。我想加載第三個控制器,但UITabBarController不加載 – Alexander

+0

你確定你的tabbarController有三個表? – sunljz

+0

檢查tabbarController.viewControllers。如果它是count == 1,則需要檢查tabBarController。 – sunljz

相關問題