您需要使用导航控制器的推ViewController
像
override func viewDidLoad() {
super.viewDidLoad()
buttonNext.addTarget(self, action: #selector(tapsOnNext), for: .touchUpInside)
}
func tapsOnNext(){
let vc = self.storyboard?.instantiateViewController(withIdentifier: "NextViewController") as? NextViewController
self.navigationController?.pushViewController(vc!, animated: true)
}
&在NextViewController
使用
buttonPrev.addTarget(self, action: #selector(tapsOnNext), for: .touchUpInside)
}
func tapsOnNext(){
self.navigationController?.popViewController(animated: true)
}
我不想弹出下一个视图控制器。当按下按钮时,我只是想继续将它们添加到堆栈中。与Twitter或Facebook类似,您可以在其中查看用户的个人资料,然后从该处点击另一个个人资料,然后再点击一个个人资料,所有这些资料都会添加到视图堆栈中。 – Timestretch
然后使用'self.navigationController?.pushViewController(vc!,animated:true)'但要小心导航堆栈。 – Jack
如果你的意思是记住内存,我的数据是硬编码的,你得到的最多级递归是3.我只是想重用故事板视图而不是制作3个模糊 – Timestretch