ios - 通过代码以模态形式使用 segue

标签 ios swift navigationcontroller

我有自定义导航栏,内容是一个按钮栏 我需要创建从我的栏按钮到我的自定义导航的 segue,类型为 present modally 但不是通过 Storyboard以编程方式 这项工作但 segue 类型是 push

self.navigationController?.pushViewController("", animated: true)

我应该如何使用 模态呈现 获取它

最佳答案

这是一个使用 NavigationController 模态呈现的简单解决方案。

yourviewcontroller *myviewc= [[yourviewcontroller alloc] init];
[self presentViewController:myviewc animated:YES completion:nil];

如果你有一个导航 Controller ,第二个。

let myvc= self.storyboard!.instantiateViewControllerWithIdentifier("MyViewController") as! ViewController
    let navc= UINavigationController(rootViewController: myvc) 
    self.presentViewController(navc, animated:true, completion: nil)

您只需为您的按钮创建一个 IBAction。本教程可以帮助您做到这一点 IBAction

希望对您有所帮助!

关于ios - 通过代码以模态形式使用 segue,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39062036/

相关文章:

ios - 快速将具有分层 TableView 的导航 Controller 放入 View Controller 中

ios - 在 iOS 中实现永久动画背景的最佳技术是什么?

ios - Firebase 存储上传在不利网络条件下失败 iOS

ios - 如何仅在滚动缓慢时才更新 tableView?

swift - Swift 3 中的 Init 已重命名为 init(describing) 错误

ios - 调用 tabbarcontroller 的 navigationController 的标题

objective-c - UIToolbar内存泄漏

iOS - 检查掩码 ip 是否有效(在 ip 范围内)

ios - 为什么苹果的闭包声明缺少参数标签

arrays - 我可以使用数组中的字符串作为 Swift 中的选择器吗?