0

我需要使用 IBAction 将数据从 UIviewController 传递到另一个 UIviewController,因为我想实现自定义过渡效果。

为了显示下一个视图,我使用了这段代码,它完美地工作:

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]

为了传递数据,我尝试了通常在 prepareForSegue 中执行的操作,因此将属性分配给 NextViewController.h

@property (assign,nonatomic) int indiceDue;

并使用该属性来传递数据

    -(void) passData
{


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

    IbaViewController*dvc = segue.destinationViewController;

    dvc.indiceDue = self.indice;
}

问题是它不起作用。我该如何解决我的问题?

4

1 回答 1

0

在 ibaction 中调用此方法:

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

    dvc.indiceDue = self.indice;

    [self.navigationController pushViewController:dvc
                                        flipStyle:MPFlipStyleFlipDirectionBit(MPFlipStyleOrientationVertical)];// or the transition that you like
于 2013-06-28T14:45:37.677 回答