我有2个视图控制器,想要从第一个到第二个导航,没有任何用户交互但基于来自http请求的变量
编辑: - 1-我试图像这样使用segue:self.performSegueWithIdentifier(" updateuser",sender:nil) 但它没有返回带有标识符' updateuser
的segue2-我想基于我的变量创建导航而无需任何用户交互
//首先是Viewcontroller
类ViewController:UIViewController {
override func viewDidLoad() {
super.viewDidLoad()
let mapViewControllerObj = self.storyboard?.instantiateViewControllerWithIdentifier("update") as? hhViewController
self.navigationController?.pushViewController(mapViewControllerObj!, animated: true)
}
}
//第二个viewcontroller
class hhViewController:UIViewController {
override func viewDidLoad() {
super.viewDidLoad()
view.backgroundColor = UIColor.whiteColor()
}
答案 0 :(得分:0)
以编程方式使用Swift3 ..我不确定,但您可以在获取变量值的函数中尝试此操作。
if var == "variablevalue" {
navigationController?.pushViewController(FirstController(), animated: true)
} else {
navigationController?.pushViewController(SecondController(), animated: true)
}
答案 1 :(得分:0)
我认为你不需要这个。你可以推动导航控制器。
让storyBoardHome = UIStoryboard(name:storyBoardName,bundle:nil)
let 1stViewController = storyBoardHome.instantiateViewController(withIdentifier: <1stViewControllerID>)
let 2ndViewController = storyBoardHome .instantiateViewController(withIdentifier: 2ndViewControllerID)
self.navigationController?.pushViewController(1stViewController/2ndViewController, animated: true)