【问题标题】:Displaying nothing in the storyboard after selecting a value from the picker iphone从选择器 iphone 中选择值后,故事板中不显示任何内容
【发布时间】:2012-09-05 04:44:43
【问题描述】:

我在程序中包含了一个 UIPicker。它包含 2 个内容,例如 A 和 B。我需要假设如果用户从选择器中选择了 A,它应该移动另一个故事板。我可以移动到另一个视图,但它什么也没显示。我将粘贴下面的代码:-

- (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]; 

           }

}

谁能告诉我为什么我得到一个空白的故事板?

【问题讨论】:

    标签: iphone xcode ios5 storyboard uipickerview


    【解决方案1】:

    要在情节提要中显示另一个场景,请执行“转场”,例如

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

    确保保留所选值的实例变量, 然后在'prepare for segue'中将此值传递给目标视图控制器,例如

    [segue.destinationViewController setChosenValue:self.pickedValue];

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2021-12-30
      • 2012-12-25
      • 2018-11-17
      • 2014-02-04
      • 2021-12-02
      • 1970-01-01
      • 2021-07-17
      • 2012-02-19
      相关资源
      最近更新 更多