0

我正在尝试将一个 int 值从第一个 VC 传递给一个自定义的第二个 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];

谁能教我我犯了什么错误???

4

1 回答 1

0

尝试:

[segue.destinationViewController setVertex:numberOfVertex];
于 2012-02-20T20:03:44.060 回答