Reputation: 4100
I have an iMessage extension and I'm having some issues with changing presentation styles. When I first open the app here is what I get:
That's how it should be. Now when I change to expanded presentation style, this is what I get:
That's also what I want. However, when I switch back to compact, this happens:
Here is my code:
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)
}
And here is a screenshot of my top constraint:
Upvotes: 1
Views: 247
Reputation: 2105
In my point of view you should not reinstantiate the bar every time you switch to compact or extend mode. You should instantiate it once, then set constraints to the top of the view. I've tried that way and it's working fine ;)
So to sum up, if you are using the storyboard
If you are not using storyboard.
Upvotes: 1
Reputation: 826
As RomOne said you should be putting it there once. Style switches should be handled by constraints
Upvotes: 0