Skip to content

Instantly share code, notes, and snippets.

@jeffcdavis
Last active August 10, 2016 21:23
Show Gist options
  • Save jeffcdavis/6e282bae708e50e043968e285212db44 to your computer and use it in GitHub Desktop.
Save jeffcdavis/6e282bae708e50e043968e285212db44 to your computer and use it in GitHub Desktop.
If you need to get back to your tabbarcontroller from a view controller not connected to your tabbarcontroller, while using SWRevealController :)
// This assumes you want the first button in your tableview cells to go back to the tabbarcontroller
override func tableView(tableView: UITableView, didSelectRowAtIndexPath indexPath: NSIndexPath) {
if (indexPath.row == 0) {
let storyboard = UIStoryboard(name: "Main", bundle: nil)
// Give the tabbar an identifier in the storyboard
let targetViewController = storyboard.instantiateViewControllerWithIdentifier("myTabBarController") as! UITabBarController
targetViewController.selectedIndex = 0 // Your index you want to open
self.revealViewController().pushFrontViewController(targetViewController, animated: true)
} else {
self.performSegueWithIdentifier("showAnotherViewController", sender: self)
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment