swift 页面跳转

一. 左右跳转:

//实例化一个将要跳转的 viewController
let secondView = SecondViewController()
//跳转
self.navigationController?.pushViewController(secondView , animated: true)

返回上一级:

self.navigationController?.popViewController(animated: true)

返回顶级(根页面):

self.navigationController?.popToRootViewController(animated: true)
另外: 将子页面中的"<Back"改为中文的"<返回"的方法:
在父页面中加入
    override func viewDidLoad() {
        super.viewDidLoad()
        
     //插入这两句,所有这个页面对应的子页面的"<Back"都改成中文的"<返回"了  let item
= UIBarButtonItem(title: "返回", style: .plain, target: self, action: nil) self.navigationItem.backBarButtonItem = item ... }
 
 
原文地址:https://www.cnblogs.com/zrcx/p/7229091.html