Die Präsentation eines view-controller programmgesteuert in swift
Hallo, ich versuche zum konvertieren der folgenden objective-C code in swift zu navigieren aus einer Ansicht-controller zu einem anderen view-controller, wenn ein button geklickt wird. jede Hilfe wäre sehr geschätzt werden
Aus der apple-Programmierhandbuch
- (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];
}
mein code ist unten angegeben, aber nicht sicher, wie die Umsetzung in der navigation-controller im storyboard meiner mainSectionViewController eingebettet ist, mit einem Navigation-Controller
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)
}
InformationsquelleAutor Magesh | 2014-12-05
Du musst angemeldet sein, um einen Kommentar abzugeben.
Wollen Sie präsentieren navController Modal?
wenn ja, das ist die Antwort
"selbst" ist die aktuelle view-controller, der die navController
Und legte es so,
Aber,
Wenn Sie möchten, navigieren Sie zwischen den viewController in der navigationController, die Sie verwenden können,
InformationsquelleAutor Edward Anthony
Machte ich eine einfache Lösung. Hier ist es..
InformationsquelleAutor A.G