Search code examples
iphonexcodemethodsstoryboardcall

-(void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender not geting called


I am working on Storyboards.I have used a table view and on its cell i have created a Segue from this table view cell prototype to a new view controller.

also i have included a method

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

    UITableViewCell *cell=sender;
    NSLog(@"%@",cell.textLabel.text);
    thirdViewController *thid=[segue destinationViewController];
    thid.strValue=cell.textLabel.text;

}

but it is not getting called.

When does this method get called..?

Any help will be Appreciated.

Thanks Vikas


Solution

  • If you want to open new Viewcontroller then try with below line hope it helps you:

           UIStoryboard *mainStoryboard = [UIStoryboard storyboardWithName:@"MainStoryboard" bundle:nil];
           Synergy *objSynergy = (Synergy *)[mainStoryboard instantiateViewControllerWithIdentifier:@"Synergy"];
          [self presentModalViewController:objSynergy animated:YES];
    

    Synergy is my new controller name you replace it with your class name change this code according to your requirement.