Alexsander Alexsander - 12 days ago 5
Swift Question

How to show UITabBarController after a move from Nib-File

I want to come back from

UIViewController
to
UITableViewController
.
UITableViewController
is subview of
UITabBarController
. I wrote following code for it. But
UITabBarController
doesn't load. I searched and found answer, but when I move by link I see Page not found. How it make programmatically? Please help me.

@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
has the following code

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


UPDATE
My
UITabBarController
. I updated it. I want to move from the third
UIViewController
to the third
UITableViewController
, but when I make it,
UITabBarController
doesn't load.

enter image description here

Still I tried it but when I move from
UIViewConroller
, UITabBarController open the first
UITabBarController
but I want
UITabBarController
opens the third
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)
}

Answer

I solved it. I changed my code and it works for me. I made that UITabBarController will select UITableViewController by index.

  @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)
    }
Comments