0

Hi i have little confusion. i am using below method in my application.how should I call this method from ant other point where i need in same view controller.

- (void) prepareForSegue: (UIStoryboardSegue *) segue sender: (id) sender

Thanks

  • See: http://stackoverflow.com/questions/23824050/how-to-navigation-using-segue/23824094#23824094 – Ricky Jun 16 '14 at 08:49

2 Answers2

0

Use this method wherever you want to segue Controllers.

[self performSegueWithIdentifier:@"yourSegueIdentifierName" sender:nil];

This method will automatically trigger the prepareForSegue method as soon as the above statement is encountered.

Dhrumil
  • 3,221
  • 6
  • 21
  • 34
  • the string @"yourSegueIdentifierName" is the same that you set in interface builder to access this segue programmtically (in case you don't know where to find it), it's a _property_ of _UIStoryboardSegue_ – nburk Jun 16 '14 at 08:51
  • I am aware about it. This was just a random name to guide the OP that here you have to insert your segue identifier name. :) – Dhrumil Jun 16 '14 at 08:53
  • haha, i guessed so, the comment wasn't for you, rather for the person who asked the question to avoid possible confusion ;) – nburk Jun 16 '14 at 09:07
  • Haha. You got me ! ;) – Dhrumil Jun 16 '14 at 09:09
  • http://stackoverflow.com/questions/24217550/replace-application-starting-view-controller-in-ios can u give me solution for this? – user3652356 Jun 16 '14 at 09:57
  • http://stackoverflow.com/questions/10428629/programatically-set-the-initial-view-controller-using-storyboards. This will help you. – Dhrumil Jun 16 '14 at 10:03
0

You should never call prepareForSegue in code. It is called for you.

The method you are looking for is...

[self performSegueWithIdentifier:@"someSegueIdentifier" sender:nil];

This will then be routed into the prepare for segue method.

Fogmeister
  • 76,236
  • 42
  • 207
  • 306
  • you are also right... http://stackoverflow.com/questions/24217550/replace-application-starting-view-controller-in-ios can u give me solution for this? – user3652356 Jun 16 '14 at 09:58