iOS 10 Messages Extension - Wrong Layout when using Storyboard Segue

前端 未结 3 814
北海茫月
北海茫月 2021-02-15 15:56

When using Segues in Messages Extension Application the layout gets messed up.
Is there any way to solve this issue while still using storrybord segues?

3条回答
  •  误落风尘
    2021-02-15 16:14

    I hope this won't always be necessary, but I ended up using a combination of a constraint outlet, presentationStyle variable, and viewDidLayoutSubviews() to overcome this bug/oversight.

    In my DetailViewController:

    @IBOutlet weak var myViewTopConstraint: NSLayoutConstraint!
    var presentationStyle: MSMessagesAppPresentationStyle?
    
    override func viewDidLayoutSubviews() {
        super.viewDidLayoutSubviews()
        if presentationStyle == .expanded {
            myViewTopConstraint.constant = 86
        } else {
            myViewTopConstraint.constant = 0
        }
    }
    

    And in my MainViewController:

    override func willTransition(to presentationStyle: MSMessagesAppPresentationStyle) {
        if let detailController = presentedViewController as? DetailViewController {
            detailController.presentationStyle = presentationStyle
        }
    }
    

    And in case it makes a difference, my segue presents modally as a Page Sheet.

提交回复
热议问题