我正在制作全帧子视图,(子视图的框架=超级视图的边界)
我做了如下的扩展
[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)]>"
将尝试通过打破约束来恢复
将 NSUserDefault NSConstraintBasedLayoutVisualizeMutuallyExclusiveConstraints 设置为 YES 以在发生这种情况时自动调用 -[NSWindow VisualizeConstraints:]。和/或,中断 objc_exception_throw 以在调试器中捕获它。
你能解释一下我错过了什么吗?