簡體   English   中英

視圖控制器顯示不正確

[英]View Controllers not being presented correctly

函數執行完畢后,我想回到我的ProfileTabViewController。 我想返回到視圖控制器,保持ProfileTabViewControllers之前相同的導航欄和UITabBarController。 我現在擁有它的方式將其發送到ProfileTavViewController,但是我丟失了導航欄和標簽欄。 我如何將其發送回原始的ProfileTabViewController。 第一個圖像是原始ViewController,第二個圖像是當它發送回時。

原始的ProfileTabViewController 當我退回

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

} //使用流行音樂

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM