在消息扩展应用程序中使用 Segue 时,布局会变得困惑。
有什么办法可以在仍然使用 Storrybord segues 的同时解决这个问题?
截图:
(注意:第一个和第二个 View/ViewController 是相同的。segue-type 无关紧要)
扩展演示样式:
简洁的展示风格:
更新 1:
顶部和底部布局指南在 segue 后重置
附言有人可以创建一个新的“消息扩展”标签吗?
最佳答案
我希望这并不总是必要的,但我最终使用了约束导出、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 以模态方式呈现为页面表。
关于autolayout - iOS 10 消息扩展 - 使用 Storyboard Segue 时布局错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38593054/