gpt4 book ai didi

ios - AutoLayout 约束和 UIPopoverPresentationController

转载 作者:塔克拉玛干 更新时间:2023-11-02 21:05:06 25 4
gpt4 key购买 nike

AutoLayout 似乎每一步都在与 View 大小作斗争。

我有一个用于用户输入的 View Controller ,而 AutoLayout 似乎坚定不移地决定让我的 View 高 667 像素。

我尝试过许多布局设置变体、许多内容压缩和抗压缩组合,无论我做什么,AutoLayout 都能找到一种将 View 拉伸(stretch)到 667 像素高的方法。

我使用 Reveal,一个显示布局框架、约束等的应用程序 (revealapp.com)它向我展示了 UIPopoverPresentationController 正在添加它自己的自动调整大小约束。

这是我的 View 在呈现时的大致外观......

enter image description here

请注意,即使我将“接受”UIButton 设置为 30 像素高且优先级为 1000,AutoLayout 仍会拉伸(stretch)它以满足其奇怪的 667 像素高要求。

当我运行该应用程序时,弹出窗口的外观如下...

enter image description here

当我让 Reveal 检查正在运行的应用程序时,我将范围缩小到弹出窗口,这就是 Reveal 显示的...

enter image description here

enter image description here

注意 UIPopoverPresentationController 本身有这些限制。

如何控制 UIPopoverPresentationController 设置的约束??

最佳答案

尝试使用 boundingRectWithSize(_:options:attributes:context:) NSString 来确定标签的高度。

完成后,您可以通过添加标签创建的任何额外高度来预测弹出窗口的大小。您可以使用它来设置您正在呈现的 View Controller 的 preferredContentSize 属性。

关于ios - AutoLayout 约束和 UIPopoverPresentationController,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37999365/

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