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

标签 ios uinavigationcontroller uicontainerview ios10 imessage

我正在尝试在 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/

相关文章:

ios - 为什么我的 UINavigtionController 栏只有在我覆盖它时才会在 iOS 7 上错误定位?

ios - 在容器 View 中刷新单 View Controller

ios - 为什么在页面 View Controller 中使用 KVO 进行观察时应用程序崩溃?以及如何使 KVO 生效?

ios - 从所选视频中获取图像 UIImagePickerController

iphone - .plist 中的可变字符串集合,替代方案?

ios - 如何在协议(protocol)中设置读写内部、只读外部属性

ios - CLLocationManager 没有定义 requestAlwaysAuthorization 或 requestWhenInUseAuthorization

iphone - 调整 iPhone 上 UINavigationController 一部分的 viewController View 的大小

IOS ViewController 导航路径 - 如何以编程方式向后导航

ios - 如何修复 iOS Storyboard 中的不等式约束模糊性?