ProfileTabViewController

ProfileTabViewController

函数执行完毕后,我想回到我的ProfileTabViewController。我想返回到视图控制器,保持ProfileTabViewControllers之前相同的导航栏和UITabBarController。我现在拥有它的方式将其发送到ProfileTavViewController,但是我丢失了导航栏和标签栏。我如何将其发送回原始的ProfileTabViewController。第一个图像是原始ViewController,第二个图像是当它发送回时。

ios - View Controller显示不正确-LMLPHP
ios - View Controller显示不正确-LMLPHP

@IBAction func updateAction(_ sender: Any) {
     let newInterests = options.joined(separator: " , ")

    if newInterests == ""{
        showAlert(message: "Please select at least one interest.")
    }else{
       updateFunction()
        let storyboard = UIStoryboard(name: "Main", bundle: nil)
        let vc = storyboard.instantiateViewController(withIdentifier: "ProfileTabViewController") as! UIViewController
        self.navigationController?.present(vc, animated: true, completion: nil)
    }

}

最佳答案

呈现ViewController时,它不会显示导航栏,因为呈现取决于UIViewController而不是NavigationViewcontroller。

您必须使用popViewController方法获取导航栏。

for controller in self.navigationController?.viewControllers {
  if controller is ProfileViewController {
    self.navigationController!.popToViewController(controller, animated: true)
    break
}


}
//使用流行音乐

09-11 19:15