Recherche…


Introduction

Un objet UIStoryboard encapsule le graphique du contrôleur de vue stocké dans un fichier de ressources de storyboard Interface Builder. Ce graphique de contrôleur de vue représente les contrôleurs de vue pour tout ou partie de l'interface utilisateur de votre application.

Obtenir une instance de UIStoryboard par programmation


RAPIDE:

Vous pouvez obtenir une instance de UIStoryboard par programmation comme suit:

    let storyboard = UIStoryboard(name: "Main", bundle: nil)

où:

  • name => le nom du storyboard sans extension
  • bundle => l'ensemble contenant le fichier de storyboard et ses ressources associées. Si vous spécifiez nil, cette méthode examine le bundle principal de l'application en cours.

Par exemple, vous pouvez utiliser l'instance créée ci-dessus pour accéder à un certain UIViewController instancié dans ce storyboard:

   let viewController = storyboard.instantiateViewController(withIdentifier: "yourIdentifier")

OBJECTIF C:

Vous pouvez obtenir une instance de UIStoryboard dans Objective-C comme suit:

 UIStoryboard *storyboard = [UIStoryboard storyboardWithName:@"MainStoryboard" bundle:nil];

Exemple d'accès à UIViewController instancié dans ce storyboard:

MyViewController *myViewController = [storyboard instantiateViewControllerWithIdentifier:@"MyViewControllerIdentifier"];

Ouvrir un autre storyboard

let storyboard = UIStoryboard(name: "StoryboardName", bundle: nil)
let vc = storyboard.instantiateViewController(withIdentifier: "ViewControllerID") as YourViewController
self.present(vc, animated: true, completion: nil)


Modified text is an extract of the original Stack Overflow Documentation
Sous licence CC BY-SA 3.0
Non affilié à Stack Overflow