-1

On button click I want to navigate to next page. My storyboard id = first AND class = ViewController where i want to navigate its storyboard id = next and class = second. how to navigate to it. how to do it in objective c??

MahajanSagar
  • 740
  • 1
  • 6
  • 21
  • show your tried code – Anbu.Karthik Oct 05 '17 at 05:35
  • i dont know how to do it in objective c?? As i know in swift ?? dont have idea – MahajanSagar Oct 05 '17 at 05:37
  • let nextcontroller = self.storyboard?.instantiateViewController(withIdentifier: "next") as! second self.navigationController?.pushViewController(nextcontroller, animated: true) – MahajanSagar Oct 05 '17 at 05:41
  • Brother! First of all, welcome to Stackoverflow. Before asking any questions in this forum. Try to search first, if not getting anything what you're looking for. Then, shoot your question here. Also, read the FAQ of Stackoverflow before posting questions. – Praveenkumar Oct 05 '17 at 06:26
  • Thanks for your advice, but i am not getting any answers from here. . And i read all questions and answers related to it . . . :) – MahajanSagar Oct 05 '17 at 06:33

1 Answers1

3

In Obj-C

//Write here your's storyboard name
UIStoryboard *storyboard = [UIStoryboard storyboardWithName:@"myNewStoryboard" bundle:nil];
//Now write your next view controller and write your storyboard id.
MyNewViewController *myNewVC = (MyNewViewController *)[storyboard instantiateViewControllerWithIdentifier:@"MyNewViewController"];
[self.navigationController pushViewController:myNewVC animated:YES];

In Swift

//Write here your's storyboard name
let storyboard: UIStoryboard = UIStoryboard.init(name: "myNewStoryboard", bundle: nil)
 //Now write your next view controller and write your storyboard id.
let myNewVC = storyboard.instantiateViewController(withIdentifier: "MyNewViewController") as? MyNewViewController
self.navigationController?.pushViewController(myNewVC!, animated: true)
vivek
  • 248
  • 3
  • 6