代码之家  ›  专栏  ›  技术社区  ›  Div

从选择器iphone中选择值后,在情节提要中不显示任何内容

  •  1
  • Div  · 技术社区  · 13 年前

    我在程序中包含了一个UIPicker。它包含两个内容,例如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]; 
    
               }
    

    }

    有人能告诉我为什么我会得到一个空白的故事板吗?

    1 回复  |  直到 13 年前
        1
  •  1
  •   SPA    13 年前

    要在故事板中显示另一个场景,您可以执行“segue”,例如。

    [self-performSegueWithIdentifier:@“demo”sender:self];

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

    [segue.destinationViewController setChosenValue:self.pickedValue];