使用IBAction传递数据

时间:2013-06-25 07:45:58

标签: ios objective-c uistoryboardsegue ibaction pass-data

我需要将数据从UIviewController传递到另一个带有IBAction的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;
}

问题是它不起作用。我怎样才能解决我的问题?

1 个答案:

答案 0 :(得分: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