gpt4 book ai didi

ios - 如何防止导航栏随着 MSMessagesViewController -> UIContainerView -> UINavigationController -> UITableViewController 消失?

转载 作者:行者123 更新时间:2023-12-01 18:43:54 25 4
gpt4 key购买 nike

我正在尝试在 iMessage 应用程序(iOS 10)中放置一个带有表格 View Controller 的导航 Controller 。当我把 UINavigationControllerUIContainerView 内在 MSMessagesViewController 内.

Appearance when compact.

但是,这在展开 View 时会中断。 UINavigationBar Controller 消失了。

Broken appearance when expanded.

我该如何解决这个问题,还是我采取了错误的方法?

最佳答案

让我先假设您使用了 view.addSubview添加您的UITableViewControllerMSMessagesAppViewController
为了正确显示导航栏。确保您已正确设置所有约束。这是我的示例,希望这对您有用:

//嵌入新的 Controller 。 WWDC 中展示的 VC 推荐方式(冰淇淋示例)。丑陋但有效
addChildViewController( Controller )

view.addSubview(controller.view)
让 viewRect = view.bounds
Controller .view.frame = viewRect
controller.view.translatesAutoresizingMaskIntoConstraints = false

controller.view.leftAnchor.constraint(equalTo: view.leftAnchor).isActive = true
controller.view.rightAnchor.constraint(equalTo: view.rightAnchor).isActive = true
controller.view.topAnchor.constraint(equalTo: topLayoutGuide.bottomAnchor).isActive = true

如果presentationStyle == .compact {
controller.view.bottomAnchor.constraint(equalTo: view.bottomAnchor).isActive = true
} 别的 {
controller.view.bottomAnchor.constraint(equalTo: bottomLayoutGuide.topAnchor).isActive = true
}

controller.didMove(toParentViewController: self)

这是 Apple Developer Forum 上解决我的问题的帖子的链接:https://forums.developer.apple.com/thread/52049

关于ios - 如何防止导航栏随着 MSMessagesViewController -> UIContainerView -> UINavigationController -> UITableViewController 消失?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38426146/

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