简体   繁体   English

以全屏模式演示样式使用 segue 时如何仍然显示导航栏?

[英]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.过去一年我没有构建 iOS 应用程序,因为我必须专注于 Android 开发。 and there are a lot of changes in iOS 13 development并且 iOS 13 开发中有很多变化

I have some VCs in navigation controller like this我在导航控制器中有一些像这样的 VC 在此处输入图片说明

when I use push segue from VC1 to VC2 and back to VC1 , then it will make it like a cards like this.当我使用push segue 从 VC1 到 VC2 并返回到 VC1 时,它将使它像这样的卡片。 here is the code I use when the button in the first VC is clicked这是我单击第一个 VC 中的按钮时使用的代码

@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我试图在 iOS 13 fullscreen 中阅读这个Presenting modal ,所以我像这样制作全屏模式 segue

在此处输入图片说明

but it will make the navigation bar in VC2 (that blue vc) will not show.但它会使 VC2 中的导航栏(即蓝色 vc)不显示。

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但是当我运行该应用程序时,我无法在第二个 VC 中获得该导航栏,使用全屏模式 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我真的需要在 iOS 13 之前完全相同的行为。比如使用 push segue 和导航栏仍然在顶部而不像卡片

how to do that ?怎么做 ?

Let's then refresh your mind in iOS a bit.然后让我们在 iOS 中稍微刷新一下您的想法。

PUSH requires navigationController. PUSH需要导航控制器。 This makes the new screen slides to the leading side.这使得新屏幕滑动到前导侧。 If there's no navigationController, then the new screen will be presented modally instead.如果没有navigationController,那么新画面将被代替模态呈现 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.如果我们想让新屏幕弹出并且用户返回到前一个屏幕,我们在代码中使用POP

PRESENT does not require navigationController. PRESENT不需要导航控制器 This makes the new screen slide up.这使得新屏幕向上滑动。 We use DISMISS in code if we want to dismiss it.如果我们想关闭它,我们在代码中使用DISMISS 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?现在,iOS 13.0 在呈现屏幕方面有哪些新功能? 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我真的需要在 iOS 13 之前完全相同的行为。比如使用 push segue 和导航栏仍然在顶部而不像卡片

You will need to use PUSH not PRESENT .您将需要使用PUSH而不是PRESENT Tap on that segue again, and select SHOW (this is the push equivalent in Interface Builder).再次点击该 segue,然后选择SHOW (这是 Interface Builder 中的推送等效项)。 And also tap on that VC1 and click on Xcode's EDITOR menu, Embed In, and click NavigationController.并且点击那个 VC1 并点击 Xcode 的 EDITOR 菜单,Embed In,然后点击 NavigationController。

If you embed VC2 into its own Navigation Controller it will display with the navigation bar.如果您将 VC2 嵌入到它自己的导航控制器中,它将与导航栏一起显示。 So your view should look like UINav->VC1->UINav->VC2所以你的视图应该看起来像 UINav->VC1->UINav->VC2

When presenting a view full screen and modal, all previous Navigation Controllers don't form part of the new stack.当呈现全屏和模态视图时,所有以前的导航控制器不构成新堆栈的一部分。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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