gpt4 book ai didi

iphone - NSLayoutConstraint错误: making full subview

转载 作者:行者123 更新时间:2023-12-03 17:54:34 25 4
gpt4 key购买 nike

我正在制作全帧 subview ,( subview 的框架= super View 的绑定(bind))

我做了如下扩展

[self addConstraints:[NSLayoutConstraint
constraintsWithVisualFormat:@"H:|-0-[subview]-0-|"
options:NSLayoutFormatDirectionLeadingToTrailing
metrics:nil
views:NSDictionaryOfVariableBindings(subview)]];
[self addConstraints:[NSLayoutConstraint
constraintsWithVisualFormat:@"V:|-0-[subview]-0-|"
options:NSLayoutFormatDirectionLeadingToTrailing
metrics:nil
views:NSDictionaryOfVariableBindings(subview)]];

但是运行时出现错误,显示以下错误。

"<NSAutoresizingMaskLayoutConstraint:0x1001bb700 h=--& v=--& H:[IUView:0x10015dcc0(960)]>",
"<NSLayoutConstraint:0x1001911d0 H:|-(0)-[IUBGView:0x1001783f0] (Names: '|':IUView:0x10015dcc0 )>",
"<NSLayoutConstraint:0x1001910e0 H:[IUBGView:0x1001783f0]-(0)-| (Names: '|':IUView:0x10015dcc0 )>",
"<NSLayoutConstraint:0x10017bbf0 H:|-(0)-[NSImageView:0x100160050] (Names: '|':IUBGView:0x1001783f0 )>",
"<NSLayoutConstraint:0x10015d7f0 H:[NSImageView:0x100160050]-(0)-| (Names: '|':IUBGView:0x1001783f0 )>",
"<NSAutoresizingMaskLayoutConstraint:0x1001a6a80 h=--& v=--& H:[NSImageView:0x100160050(0)]>"

Will attempt to recover by breaking constraint

Set the NSUserDefault NSConstraintBasedLayoutVisualizeMutuallyExclusiveConstraints to YES to have -[NSWindow visualizeConstraints:] automatically called when this happens. And/or, break on objc_exception_throw to catch this in the debugger.

你能解释一下我错过了什么吗?

最佳答案

您似乎没有关闭手动创建的 View 的“translatesAutoresizingMaskInotConstraints”功能。

someView.translatesAutoresizingMaskIntoConstraints = NO;

如果您不将其设置为“否”,则 iOS 会将 springs-and-struts(例如自动调整大小 mask )设置转换为约束。这些限制与您使用视觉格式语言制定的限制相冲突。

每当您在 contains 错误输出中看到“NSAutoresizingMaskLayoutConstraint”类时,您就可以确定您尚未关闭翻译。

好的做法是,在您以编程方式创建的每个 View 上,您​​也可以关闭翻译。

关于iphone - NSLayoutConstraint错误: making full subview,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15700427/

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