gpt4 book ai didi

ios - 如何在选项卡栏 Controller 顶部呈现模态视图?

转载 作者:可可西里 更新时间:2023-11-01 06:21:25 26 4
gpt4 key购买 nike

我在导航栏上做了一个按钮。我进入模态视图。但问题是我无法将此模态视图置于选项卡栏的顶部。我该怎么办?

此外,我使用了storyboard的segue来呈现模态视图。

Enter to see storyboard image

Enter to see simulator image

最佳答案

很难从屏幕截图中看出,但似乎您想要的是标签栏变成灰色,就像 UITabBarController 中 View 的背景一样?

您从哪里呈现模态视图?如果 View Controller A 在您的选项卡栏 Controller 内,那么从 A 呈现模态视图将导致选项卡栏不会变灰。如果您从标签栏 Controller 中呈现,它应该会执行您想要的操作。

在呈现 View Controller 的代码中,而不是

present(modalViewController, animated: true, completion: completion)

尝试使用

tabBarController?.present(modalViewController, animated: true, completion: completion)

(当然,modalViewControllercompletion 是您要用于这些参数的任何内容。)

如果您使用 segue 来呈现模态 Controller ,那么同样的概念也适用。将 segue 移动到标签栏 Controller ,然后从呈现 View Controller 在标签栏 Controller 上执行它。

tabBarController?.performSegue(withIdentifier: "yourSegueIdentifier", sender: tabBarController)

关于ios - 如何在选项卡栏 Controller 顶部呈现模态视图?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/41594465/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com