Segue无法将值传递给目标VC

时间:2012-02-20 19:24:47

标签: iphone ios5 uiviewcontroller storyboard segue

我正在尝试将第一个VC的int值传递给自定义的第二个VC ..但是使用控制台,我发现它无法将值传递给第二个VC ......

在第一个VC中:

@interface ViewController ()

@end

@implementation ViewController
@synthesize numberOfVertexSlider;
@synthesize numerOfVertexLabel;
@synthesize numberOfVertex;

- (IBAction)numberOfVertexSliderChange:(id)sender {
numberOfVertex=numberOfVertexSlider.value;
NSLog(@"value :%i",numberOfVertex);
numerOfVertexLabel.text=[NSString stringWithFormat:@"%i",numberOfVertex];


-(void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender
{
  if ([segue.identifier isEqualToString:@"polygenPushVertex"]) {
     [segue.destinationViewController setVertex:self.numberOfVertex];
  }
}

在第二个VC:

@interface PolygonViewController ()

@end

@implementation PolygonViewController
@synthesize Vertex=_Vertex;

- (void)viewDidLoad
{
[super viewDidLoad];
NSLog(@"%i",_Vertex);
PolygonView *pv=[[PolygonView alloc] initWithFrame:self.view.bounds Vertex:_Vertex];
[self.view addSubview:pv];

任何人都可以教我这个错误吗?

1 个答案:

答案 0 :(得分:0)

尝试:

[segue.destinationViewController setVertex:numberOfVertex];