简体   繁体   中英

how to still show navigation bar when using segue in full screen modal presentation style?

for the past one year I have not built an iOS app because I have to concentrate in Android development. and there are a lot of changes in iOS 13 development

I have some VCs in navigation controller like this 在此处输入图片说明

when I use push segue from VC1 to VC2 and back to VC1 , then it will make it like a cards like this. here is the code I use when the button in the first VC is clicked

@IBAction func createEventButtonDidPressed(_ sender: Any) {

    // do some actions first and then
    performSegue(withIdentifier: "chooseEventName", sender: nil)
}

在此处输入图片说明

I have tried to read this Presenting modal in iOS 13 fullscreen , so I make fullscreen modal segue like this

在此处输入图片说明

but it will make the navigation bar in VC2 (that blue vc) will not show.

I have tried to select to bar to be 'Translucent navigation bar' 在此处输入图片说明

but when I run the app, I can't get that navigation bar in second VC, the navigation bar doesn't show when using fullscreen modal segue

I really need the behaviour exactly the same before iOS 13. like using push segue and the navigation bar still on top without look like a cards

how to do that ?

Let's then refresh your mind in iOS a bit.

PUSH requires navigationController. This makes the new screen slides to the leading side. If there's no navigationController, then the new screen will be presented modally instead. We use POP in code if we want to make the new screen to be popped and user to go back to the previous screen.

PRESENT does not require navigationController. This makes the new screen slide up. We use DISMISS in code if we want to dismiss it. You can add a navigationController to the next screen if you need one.

Now what's new with iOS 13.0 when it comes to presenting screens? By default, the screens will now be presented as cards, not in fullscreen.

Back to your problem:

I really need the behaviour exactly the same before iOS 13. like using push segue and the navigation bar still on top without look like a cards

You will need to use PUSH not PRESENT . Tap on that segue again, and select SHOW (this is the push equivalent in Interface Builder). And also tap on that VC1 and click on Xcode's EDITOR menu, Embed In, and click NavigationController.

If you embed VC2 into its own Navigation Controller it will display with the navigation bar. So your view should look like UINav->VC1->UINav->VC2

When presenting a view full screen and modal, all previous Navigation Controllers don't form part of the new stack.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM