Open a view programmatically with tab controller from storyboard

I was able to solve the issue by using following code:

UITabBarController *tbc = [self.storyboard instantiateViewControllerWithIdentifier:@"docovaMainTabBarController"];
tbc.selectedIndex=1;
[self presentViewController:tbc animated:YES completion:nil];

Also, remember to edit the storyboard and give the UITabBarController a storyboard ID set to docovaMainTabBarController so it can be uniquely identified within the storyboard.

Swift

  let tbc = self.storyboard.instantiateViewController(withIdentifier:"docovaMainTabBarController") as! UITabBarController
   tbc.selectedIndex = 1
   self.present(tbc, animated: true, completion:nil)

Tags:

Ios