SetNeedsDisplay not working?

I have a problem with redrawing a user view in a simple cocoa application. Drawing is based on one parameter, which is changed by a simple NSSlider. However, despite the fact that I implement the -setParameter: and -parameter methods and bind the value of the slider to this parameter in the interface builder, I cannot force the user view to redraw itself.

The code that performs the redraw is as follows:

- (void)setParameter:(int)newParameter {
  parameter = newParamter;
  NSLog(@"Updated parameter: %d", parameter);
  [self setNeedsDisplay:YES];
}

I get a message about setting a new parameter, although the view does not redraw itself. Any ideas are welcome!

+5
source share
4 answers

: [self setNeedsDisplay:YES], , . - (void)drawRect:(NSRect)rect drawRect: ?

+5

: UIView. . IB, ctrl .

+2

, NSOpenGLView, [[self openGLContext] flushBuffer] drawRect:.

+1

iOS 6 : setNeedsDisplay:YES. , : fooobar.com/questions/58039/....

, .

0

All Articles