![](/img/trans.png)
[英]Is rendering views to UIImages the correct way to go about animations in the iPhone SDK?
[英]I have a question with Swift about the correct way closing views Storyboard
我有幾個視圖,我使用這段代碼打開和關閉它們,所以我瀏覽了所有視圖。
let viewController = self.storyboard!.instantiateViewController(withIdentifier: "HomeViewController")
viewController.modalPresentationStyle = .fullScreen
self.present(viewController,animated: true, completion:nil)
我的問題是:我是真的關閉它們還是只是打開一個浪費 memory?
因此,在閱讀了明智的建議后,我做出了同樣的改變,但關於這一點我有最后一個問題,我啟動我的應用程序 int View1,然后必須移動到 View2,然后從那里移動到 View 3。當我意識到當我在 View 3 中,我打開了 View1、View2,當然還有 View 3,所以當我從 View1 跳轉到 View2 時要修復它,首先我用 pop 關閉 View1,然后用 pop 打開 View2。 當我想返回到 View3 時,我使用從 View1 移動到 View2
let storyboard = UIStoryboard(name: "Main", bundle: nil)
let viewController = storyboard.instantiateViewController(identifier: "View2")
self.navigationController?.popViewController(animated: true)
self.navigationController?.pushViewController(viewController, animated: true)
}
要返回 View3 到 View1,我使用:
self.navigationController?.popToRootViewController(animated: true)
在同一個 View 中進行 pop 和 push 是否正確?
我認為您對“我可以同時打開兩個視圖嗎?”這個想法感到困惑和擔心。
這是使用導航 Controller 的一種非常常見的方式:
“Go Next”按鈕將下一個 controller 推到導航“堆棧”上。 您會自動在導航欄上獲得一個“< 返回”按鈕。 如果您的控制器有標題,則“返回”一詞將替換為之前控制器的標題。
因此,在每個“步驟”,用戶可以:
如果我想讓用戶 go “返回開始”...例如,我可以添加一個按鈕來調用navigationController?.popToRootViewController(animated: true)
您無需擔心“打開多個視圖”。 這就是導航控制器的工作方式。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.