视图控制器无法正确显示

时间:2018-01-31 00:40:06

标签: ios swift uinavigationcontroller uistoryboard

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

original ProfileTabViewController When i get sent back

@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)
    }

}

1 个答案:

答案 0 :(得分:0)

在呈现ViewController时,它不会显示导航栏因为演示依赖于UIViewController而不是NavigationViewcontroller。

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

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

} //使用Pop

相关问题