Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

setNeedsDisplay not working?

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.

The code that does redrawing is like this:

- (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!

like image 772
Eimantas Avatar asked Nov 29 '08 07:11

Eimantas


1 Answers

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?

like image 71
e.James Avatar answered Sep 23 '22 06:09

e.James