autolayout – iOS 10消息扩展 – 使用Storyboard Segue时布局错误

在消息扩展应用程序中使用Segues时,布局变得混乱.
有没有办法解决这个问题,同时仍然使用storrybord segues?

截图:
(注意:第一个和第二个View / ViewController是相同的.segue类型无关紧要)

扩展的演示风格:


紧凑的演示风格:


更新1:

在segue之后,顶部和底部布局指南会重置

>紧凑:

> top:应该是:0但是:20
> bottom:应该是:44但是:0

>扩大:

> top:应该是:86但是:20
> bottom:应该是:44但是:0

附:有人可以创建一个新的“消息扩展”标签吗?

解决方法

我希望这并不总是必要的,但我最终使用约束出口,presentationStyle变量和viewDidLayoutSubviews()的组合来克服这个错误/疏忽.

在我的DetailViewController中:

@IBOutlet weak var myViewTopConstraint: NSLayoutConstraint!
var presentationStyle: MSMessagesAppPresentationStyle?

override func viewDidLayoutSubviews() {
    super.viewDidLayoutSubviews()
    if presentationStyle == .expanded {
        myViewTopConstraint.constant = 86
    } else {
        myViewTopConstraint.constant = 0
    }
}

在我的MainViewController中:

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

如果它有所不同,我的segue会以模式形式呈现为Page Sheet.

相关文章

当我们远离最新的 iOS 16 更新版本时,我们听到了困扰 Apple...
欧版/美版 特别说一下,美版选错了 可能会永久丧失4G,不过只...
一般在接外包的时候, 通常第三方需要安装你的app进行测...
前言为了让更多的人永远记住12月13日,各大厂都在这一天将应...