- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我在 View 中有一个 NSTextField,其中布局完全由约束控制,并且 translatesAutoresizingMaskIntoConstraints 为“否”。我尝试使用 setStringValue 来更改内容,如下所示:
[[self textfield] setStringValue:@"1\n2\n3\n"];
然后高度改为4行,这不是我想要的。我需要一个只能显示一行的 NSTextField,但我仍然可以使用向上和向下箭头键进入不同的行。就像使用 option+enter 在 NSTextField 中插入换行符一样。
我也尝试保持高度:
NSRect originalFrame = [[self textfield] frame];
[[self textfield] setStringValue:@"1\n2\n3\n"];
NSRect newFrame = [[self textfield] frame];
newFrame.size.height = originalFrame.size.height;
[[self textfield] setFrame:newFrame];
这不起作用。我检查了intrinsicContentSize,它返回(宽度=-1,高度=73)。我可以为 NSTextField 设置什么,以便高度只有一行,例如 22?
最佳答案
发生这种情况是因为您已经设置了相对于 View 的文本字段的自动布局。因此,只需通过单击高度复选框来固定文本字段的高度,如下所示:-
关于cocoa - NSTextField 中的 setStringValue 总是会改变高度,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27497076/
我对 setStringValue: 有一个独特的情况,希望有人能解决这个问题: 使用以下理论示例(非文字)代码: NSString *myVar; [myOutlet setStringValue:
我在 View 中有一个 NSTextField,其中布局完全由约束控制,并且 translatesAutoresizingMaskIntoConstraints 为“否”。我尝试使用 setStri
本质上,这是我在 NSTextFieldCell 子类中的代码: - (void)setStringValue:(NSString *)aString { [super setStringVa
我尝试使用 setString 方法来更改文本字段中的文本,但没有成功。然后我将其更改为 setStringValue 并且成功了。那么setString有什么用呢? 最佳答案 NSTextField
我有一个按钮 (IBAction),当我单击该按钮时,标签将会更改 (setStringValue)。工作完美。 有没有办法使用 (void) 方法更改标签 (setStringValue),因此该方
我已经实现了一个委托(delegate)及其 controlTextDidChange 方法,只要我在 NSTextField 中输入文本,它就会被调用。 当我通过 [field setStringV
我有大约 10 个按钮,每个按钮都有不同的名称。在选择每个按钮时,我需要将按钮的标题附加到 NSTextField,而不删除旧字符串。 我试过以下方法。 - (IBAction)nextButton:
本文整理了Java中org.apache.xmlbeans.impl.values.XmlObjectBase.setStringValue()方法的一些代码示例,展示了XmlObjectBase.s
我正在尝试为“-[NSTextField setStringValue:]”添加“符号断点”。 乍一看,这是一个类似于WWDC 2018中描述的任务。 但在我的情况下它根本不会触发。 所以我决定用谷歌
我是一名优秀的程序员,十分优秀!