setNeedsDisplay不工作? [英] setNeedsDisplay not working?
问题描述
在简单的可可应用程序中重绘自定义视图时出现问题。绘图基于由简单的NSSlider改变的一个参数。但是,虽然我实现了-setParameter:和-parameter方法,并绑定滑块的值到接口构建器中的参数,我似乎不能自定义视图重绘本身。
I have a problem redrawing a custom view in simple cocoa application. Drawing is based on one parameter that is being changed by a simple NSSlider. However, although i implement -setParameter: and -parameter methods and bind slider's value to that parameter in interface builder i cannot seem to make a custom view to redraw itself.
重绘的代码如下:
- (void)setParameter:(int)newParameter {
parameter = newParamter;
NSLog(@"Updated parameter: %d", parameter);
[self setNeedsDisplay:YES];
}
我获得有关设置新参数的消息,重绘本身。欢迎任何想法!
I DO get the message about setting the new parameter although the view doesn't redraw itself. Any ideas are welcome!
推荐答案
通常的语法是: [self setNeedsDisplay:YES]
,虽然我认为这意味着相同的事情。你是实现 - (void)drawRect:(NSRect)rect
方法,或使用 drawRect:
超类?
The usual syntax is: [self setNeedsDisplay:YES]
, although I would assume that that means the same thing. Are you implementing the - (void)drawRect:(NSRect)rect
method, or using the drawRect:
method of your superclass?
这篇关于setNeedsDisplay不工作?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!