我有一個iMessage擴展,並且在更改演示文稿樣式時遇到了一些問題。當我第一次打開應用程序時,我得到: 這就是它應該如何。現在當我改變擴展的演示風格時,這就是我得到的:
這也是我想要的。然而,當我切換回緊湊,出現這種情況:
這裏是我的代碼:爲什麼我的視圖在更改演示文稿樣式時會偏移?
override func didTransition(to presentationStyle: MSMessagesAppPresentationStyle) {
super.didTransition(to: presentationStyle)
presentSearchStickersView()
}
private func presentSearchStickersView() {
let controller = (storyboard?.instantiateViewController(withIdentifier: "SearchStickersViewController"))! as! SearchStickersViewController
controller.view.backgroundColor = #colorLiteral(red: 1, green: 1, blue: 1, alpha: 1)
controller.searchDelegate = self
for child in childViewControllers {
child.willMove(toParentViewController: nil)
child.view.removeFromSuperview()
child.removeFromParentViewController()
}
self.addChildViewController(controller)
self.view.addSubview(controller.view)
}
我這樣做了,但是在展開後,我的視圖的頂部部分隱藏在導航欄的後面。這就是爲什麼我代表視圖控制器 –
您是否使用過「頂部佈局指南」約束? – RomOne
是的,我使用了'頂部佈局指南'。我添加了一個屏幕截圖 –