gpt4 book ai didi

objective-c - NSPopover 在一侧填充内容

转载 作者:行者123 更新时间:2023-12-03 16:41:53 24 4
gpt4 key购买 nike

我有两个 NSPopover,它们的设置完全相同(只是链接来自 IB 的自定义 NSView)。两者都弹出得很好,但其中一个似乎将内容偏移了大约 20 像素。

这个 NSPopover 没有(正确地)填充内容......

no padding

但是这个比骑行一侧增加了大约 20 像素。

padding

这是IB中列出的两个 View

enter image description here

如您所见,搜索栏应该像左侧一样固定在右侧,但由于某种原因并非如此。起初我以为这是一个约束问题,但在搞砸了一段时间后我可以确认它不是。

有什么线索吗?

编辑:决定对 View 进行子类化并填充其矩形,得到了一些非常奇怪的结果! View 似乎有所偏移。我不知道为什么会这样......

enter image description here enter image description here

最佳答案

来自here ,这引起了我的注意(强调我的):

The principle circumstance in which you should not call setTranslatesAutoresizingMaskIntoConstraints: is when you are not the person who specifies a view’s relation to its container. For example, an NSTableRowView instance is placed by NSTableView. It might do this by allowing the autoresizing mask to be translated into constraints, or it might not. This is a private implementation detail. Other views on which you should not call setTranslatesAutoresizingMaskIntoConstraints: include an NSTableCellView, a subview of NSSplitView, an NSTabViewItem’s view, or the content view of an NSPopover, NSWindow, or NSBox. For those familiar with classic Cocoa layout: If you would not call setAutoresizingMask: on a view in classic style, you should not call setTranslatesAutoresizingMaskIntoConstraints: under autolayout.

它适用于你吗?

关于objective-c - NSPopover 在一侧填充内容,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16548181/

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