Question

I'need to pass data from a UIviewController to another UIviewController with an IBAction because I want to implement a custom transition effect.

to show the next view I use this code, it work perfectly:

NSString * storyboardName = @"MainStoryboard";
NSString * viewControllerID = @"NextViewController"; // si imposta nello storyboard, subito sotto la classe di appartenenza nell'identity ispector
UIStoryboard * storyboard = [UIStoryboard storyboardWithName:storyboardName bundle:nil];
NextViewController * controller = (NextViewController *)[storyboard 

instantiateViewControllerWithIdentifier:viewControllerID];

[self passData]

To pass data I tried what I usually do in prepareForSegue, so assign a property to NextViewController.h

@property (assign,nonatomic) int indiceDue;

and use that property to pass data

    -(void) passData
{


     UIStoryboardSegue* segue = [[UIStoryboardSegue alloc]init];

    IbaViewController*dvc = segue.destinationViewController;

    dvc.indiceDue = self.indice;
}

The problem is that it don't work. How can I solve my problem?

Was it helpful?

Solution

Call this method inside the ibaction:

NextView*dvc = [self.storyboard instantiateViewControllerWithIdentifier:@"NextView"];;

    dvc.indiceDue = self.indice;

    [self.navigationController pushViewController:dvc
                                        flipStyle:MPFlipStyleFlipDirectionBit(MPFlipStyleOrientationVertical)];// or the transition that you like
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top