1

プログラムに UIPicker を含めました。たとえば、A と B の 2 つのコンテンツが含まれています。必要なのは、ユーザーがピッカーから 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]; 

           }

}

空白のストーリーボードが表示される理由を教えてください。

4

1 に答える 1

1

使用するストーリーボードで別のシーンを表示するには、「セグエ」を実行します。

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

選択した値のインスタンス変数を保持することを確認してから、「セグエの準備」でこの値を宛先ビューコントローラーに渡します。

[segue.destinationViewController setChosenValue:self.pickedValue];

于 2012-09-12T08:30:32.027 に答える