1

我刚开始学习,所以请放轻松...

目标是获取选取器中所选行的文本值,并将其显示在另一个视图的标签中。

现在我很难存储字符串值,一切都编译和加载,但第二个视图中的标签保持空白。请让我去noobify。

//String taken from selected pickerview line and stored in selectedstring
NSString *string = [NSString stringWithFormat:@"You Selected: %@",[_platforms objectAtIndex:row]];
Selectedstring.text = string;

在“下一个视图”按钮按下:

- (IBAction)NextView:(id)sender {
SecondView *secondview = [[SecondView alloc]init];

self.SecondViewData = secondview;
SecondViewData.passedValue = Selectedstring.text;

[self presentViewController:secondview animated:YES completion:nil];

然后在下一个视图的“viewdidload”区域中,我有:

label.text = passedValue;
4

2 回答 2

0

您只需要在 ViewWillAppear 而不是 viewDidLoad 中编写以下语句。

label.text = 传递值;

谢谢

于 2012-11-06T11:01:02.313 回答
0
- (void)pickerView:(UIPickerView *)pickerView didSelectRow: (NSInteger)row inComponent:(NSInteger)component {
    SecondView *secondview = [[SecondView alloc]init];

self.SecondViewData = secondview;
SecondViewData.passedValue = Selectedstring.text;

[self presentViewController:secondview animated:YES completion:nil];
secondview.label.text = passedValue;  //passing values to uilabel
}
于 2012-11-06T07:29:30.967 回答