1

I just started learning so take it easy on me...

The goal is to take the text value of the selected row in the picker and display that in a label in another view.

Right now I'm having difficulty storing the string value, everything compiles and loads but the label in the second view remains blank. De-noobify me please.

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

On "next view" button press:

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

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

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

And then in the "viewdidload" area of the next view I have:

label.text = passedValue;
leppie
  • 115,091
  • 17
  • 196
  • 297
Bogiematch
  • 27
  • 7

2 Answers2

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
}
NANNAV
  • 4,875
  • 4
  • 32
  • 50
0

you just need to write below statement in ViewWillAppear instead of viewDidLoad.

label.text = passedValue;

thanks

Hindu
  • 2,894
  • 23
  • 41