0
votes

I have a UIViewController that contains a UITableView. The table view contains a custom UITableViewCell. The custom cell was built in interface builder and has a nib. In my main storyboard, I dragged a segue from the custom table view cell to the destination view controller. I set up the bare bones essentials in prepareForSegue, set a break point, but it never gets called.

I'm not that accustomed to using a UITableView in a view controller. I usually use a UITableViewController, but requirements dictate using the table view in a view controller. My initial assumptions is that most methods of doing things would be nearly identical, but I'm finding that not to be the case.

I tried setting the segue from the view controller itself and using didSelectRowAtIndexPath, and though it worked, the transition to the destination view controller was jerky.

Can anyone suggest what I might be missing in order to cause the prepareForSegue method to fire?

-(void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender{
    GaugeViewController *destination = [segue destinationViewController];
    [destination setGaugeID:@"1"];
}

Thanks!

1
Can you please post some of your code?wigging
I don't have code to post for this situation. I have created the segue in IB and set a breakpoint in prepareForSegue and it's not calledPheepster
You must have some code somewhere in your project since you're calling prepareForSegue.wigging
see edits. Like I said, not much to show. Really just trying to figure out why this method won't firePheepster
Are you trying to do a push segue? If so, is your controller embedded in a navigation controller?rdelmar

1 Answers

-1
votes

You need to refer to the identity of the segue in the Storyboard, something like this:

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

    GaugeViewController *destination = segue.destinationViewController;

    if([segue.identifier isEqualToString:@"yourSegue"]) {
       NSLog(@"prepareForSegue called");
       [destination setGaugeID:@"1"];
    }else {
       // do something else
    }

}

Also don't forget to set the Identifier in the Storyboard.

enter image description here

Remember that push segues are used with Navigation Controllers and a modal segue can be dragged from view controller to view controller.