Search code examples
iphonexcodeios5storyboarduipickerview

Displaying nothing in the storyboard after selecting a value from the picker iphone


I have included a UIPicker in the program.And it contains 2 contents for eg A and B.What i need is suppose if the user has selected A from the picker, it should move the another storyboard. I am able to move to another view but it is showing nothing. I will paste the code below :-

- (void)pickerView:(UIPickerView *)thePickerView didSelectRow:(NSInteger)row inComponent:(NSInteger)component 

 {

     DemoViewController *demo =[[DemoViewController alloc] init];

     AnotherViewController *another =[[AnotherViewController alloc] init];

     NSString *content=[aray objectAtIndex:row];


      if ([content isEqualToString:@"A"]) 
      {

            [self presentModalViewController:demo animated:YES]; 

      } 
      else {

            [self presentModalViewController:another animated:YES]; 

           }

}

Can anyone please tell me why I am getting a blank storyboard?


Solution

  • to show another scene in a storyboard you use perform a 'segue', e.g.

    [self performSegueWithIdentifier:@"demo" sender:self];

    making sure to keep an instance variable of the picked value, and then in the 'prepare for segue' you pass this value to the destination view controller, e.g.

    [segue.destinationViewController setChosenValue:self.pickedValue];