您好我想将下列目标C代码转换为swift,以便在单击按钮时从一个视图控制器导航到另一个视图控制器。任何帮助,将不胜感激在swift中以编程方式呈现视图控制器
这是从苹果的编程指南采取
- (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];
}
我的代码如下所示,但不知道如何在导航控制器实现,在故事板我mainSectionViewController嵌有导航控制器
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)
}