1

学び始めたばかりなので、気楽に...

目標は、ピッカーで選択した行のテキスト値を取得し、それを別のビューのラベルに表示することです。

現在、文字列値を保存するのに問題があり、すべてがコンパイルおよびロードされますが、2番目のビューのラベルは空白のままです。私を非難してください。

//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
- (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 に答える
0

viewDidLoadの代わりにViewWillAppearに以下のステートメントを記述する必要があります。

label.text = passValue;

ありがとう

于 2012-11-06T11:01:02.313 に答える