Präsentation eines View Controllers programmgesteuert in swift

Hi Ich versuche, den folgenden Ziel-C-Code in Swift zu konvertieren, um von einem Ansichtscontroller zu einem anderen Ansichtscontroller zu navigieren, wenn auf eine Schaltfläche geklickt wird. Jede Hilfe wäre sehr dankbar

Dies stammt aus dem Programmierhandbuch von Apple

  - (void)add:(id)sender {
 // Create the root view controller for the navigation controller
 // The new view controller configures a Cancel and Done button for the
 // navigation bar.
   RecipeAddViewController *addController = [[RecipeAddViewController alloc]
                   init];

 // Configure the RecipeAddViewController. In this case, it reports any
 // changes to a custom delegate object.
   addController.delegate = self;

 // Create the navigation controller and present it.
  UINavigationController *navigationController = [[UINavigationController alloc]
                         initWithRootViewController:addController];
  [self presentViewController:navigationController animated:YES completion: nil];
  }

ein Code ist unten angegeben, aber nicht sicher, wie er im Navigationscontroller implementiert werden soll. Im Storyboard ist mein mainSectionViewController in einen Navigationscontroller eingebette

    func sectionBtnClicked (sender: UIButton!) {


        let sectionController = self.storyboard?.instantiateViewControllerWithIdentifier("mainSectionsVC") as mainSectionViewController


        let navController = UINavigationcontroler. ///not sure what actually comes here, any help would be appreciated


        self.presentViewController(navController, animated: true, completion: nil)


}

Antworten auf die Frage(4)

Ihre Antwort auf die Frage