[英]NSPredicateEditor does not resize NSTextField
Is there a workable way to make NSPredicateEditor
resize NSTextField
?有没有可行的方法让
NSPredicateEditor
调整NSTextField
的大小?
All I got is to subclass NSPredicateEditorRowTemplate
and write in my class the following function:我得到的只是
NSPredicateEditorRowTemplate
并在我的 class 中写入以下 function:
- (void)setTextFieldFrameWithPredicateEditor:(NSPredicateEditor *)predicateEditor{
NSArray *arr = [self templateViews];
NSView *view = [arr lastObject];
NSSize needSize = NSMakeSize(NSMaxX(predicateEditor.frame), 17);
[view setFrameSize:needSize];
}
There is no effect from setting anchors(margins) by [view setAutoresizingMask:(NSViewMaxXMargin | NSViewWidthSizable)]
通过
[view setAutoresizingMask:(NSViewMaxXMargin | NSViewWidthSizable)]
设置锚点(边距)没有效果
I call this function every time the show NSPredicateEditor by pressing a button, and every time in function -(IBAction)predicateEditorChanged:(NSPredicateEditor *)sender
.每次通过按下按钮显示 NSPredicateEditor 时,我都将其称为 function,并且每次在 function
-(IBAction)predicateEditorChanged:(NSPredicateEditor *)sender
中。 It seems working correctly, but when many times I change the settings NSPredicateEditor at some time resizing starts to work not correct.它似乎工作正常,但是当我多次更改设置 NSPredicateEditor 时,有时调整大小开始工作不正确。
Any help please.请任何帮助。
One option would be to create a custom NSPredicateEditorRowTemplate and override the templateViews method.一种选择是创建自定义 NSPredicateEditorRowTemplate 并覆盖 templateViews 方法。
Like this:像这样:
- (NSArray *)templateViews {
NSArray *views = [super templateViews];
NSView *lastView = [views lastObject];
NSRect viewFrame = lastView.frame;
viewFrame.size.width = 100.0f;
lastView.frame = viewFrame;
return views;
}
And then set the width to whatever you need it to be.然后将宽度设置为您需要的任何值。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.