iOS – Push viewController from code and storyboard

Objective-C:

PlaceViewController *newView = [self.storyboard instantiateViewControllerWithIdentifier:@"storyBoardIdentifier"];
[self.navigationController pushViewController:newView animated:YES];

Please do notice below points,

  1. your storyboard identifier is correct.

  2. The root view have navigation Controller.

Swift:

let newView = self.storyboard?.instantiateViewController(withIdentifier: "storyBoardIdentifier") as! PlaceViewController
self.navigationController?.pushViewController(newView, animated: true)

Leave a Comment