gpt4 book ai didi

Swift 安全区布局指南和视觉格式语言

转载 作者:IT王子 更新时间:2023-10-29 05:11:54 26 4
gpt4 key购买 nike

我想使用 Apple 的视觉格式语言将 View 限制为新的 Safe Area Layout Guide在 iOS 11 中。但是,我得到一个异常(exception):

-[NSLayoutYAxisAnchor nsli_superitem]: unrecognized selector sent to instance 0x1c447ed40

    //Make View Dictionary
var views: [String: Any] = ["left": self.leftContainer]

//Check swift version and add appropriate piece to the view dictionary
if #available(iOS 11, *) {
views["topGuide"] = self.view.safeAreaLayoutGuide.topAnchor
}else{
views["topGuide"] = self.topLayoutGuide
}

//Make the constraint using visual format language
let leftVertical = NSLayoutConstraint.constraints(withVisualFormat: "V:[topGuide][left]|", options: [], metrics: nil, views: views)

//Add the new constraint
self.view.addConstraints(vertical)

我喜欢可视格式语言的原因是因为在某些情况下您可以用更少的代码添加很多约束。

有什么想法吗?

最佳答案

I want to use Apples visual format language to constrain a view to the new Safe Area Layout Guide

你不能。无法通过视觉格式语言访问安全区域布局指南。我已经提交了一个错误,我建议你也这样做。

关于Swift 安全区布局指南和视觉格式语言,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/46479288/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com