簡體   English   中英

出現 VC 時顯示取消按鈕,按下同一個 VC 時不顯示取消按鈕

[英]Display cancel button when the VC is presented, don't display cancel button when the same VC is pushed

我有一個需要在兩個地方顯示的 ViewController。

首先,VC 需要使用其導航欄中的取消按鈕來展示和關閉。

其次,VC 需要推送到導航堆棧(它也以模態方式呈現)並且無法關閉(用戶必須使用導航堆棧中的后退按鈕)。

我可以在兩個地方正確顯示 VC,但不能正確使用關閉按鈕。 當我將取消欄按鈕項添加到 VC 時,它在兩種情況下都會出現。 如何在 VC 出現時顯示取消按鈕並在 VC 被按下時隱藏它?

使用 isBeingPresented 你可以管理你的取消按鈕,

        if self.isBeingPresented {
           debugPrint("Controller is Presented")
        } else {
            debugPrint("Controller is Pushed")
         }

暫無
暫無

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

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