I have the iMessage extension, and I have some problems with the guide to getting the layout started. I have an MSMessagesAppViewController that handles changes between presentation styles. In my extension, I have a button. When it is clicked, I move on to the advanced presentation style, and then present the view controller modulo. Here's the problem: my user interface in the second VC is hiding behind the top navigation bar. I thought it was strange when I set my limits in the top guide. So I broke through my code and started debugging the top layout guide. I noticed that after moving to the advanced presentation style, topLayoutGuide.length = 86. Here's how it should be. But when I present the second view controller modulo, the top layout guide reset is 0. Why is this not the way it should be? Here is my code:
In my main viewController:
@IBAction func addStickerButtonPressed(_ sender: AnyObject) { shouldPerformCreateSegue = true theSender = sender requestPresentationStyle(.expanded) } override func didTransition(to presentationStyle: MSMessagesAppPresentationStyle) { if presentationStyle == .expanded { if shouldPerformCreateSegue == true { shouldPerformCreateSegue = false performSegue(withIdentifier: "CreateStickerSegue", sender: theSender)//here is where I present the new viewController } else { searchBar.becomeFirstResponder() searchBar.placeholder = nil searchBar.showsCancelButton = true searchBar.tintColor = UIColor.white } } else { searchBar.showsCancelButton = false } print(topLayoutGuide.length) //This prints out 86 }
In another modular representation of the controller:
override func viewWillAppear(_ animated: Bool) { super.viewWillAppear(animated) self.view.addConstraint(navBar.topAnchor.constraint(equalTo: topLayoutGuide.bottomAnchor)) print(topLayoutGuide.length)
ios autolayout swift imessage
A tyshka
source share