Question

I'm working on the GUI of my application. I have a main view embedded into a NSScrollView. Its content is refreshed when the user clicks a button. It then determines the required height for displaying the content. The view is not displayed well, there are a lot of glitches, of items displayed twice... I know the problem is when I set the view size with [self setBounds: ...]. Do you know how I can change the view size? Here is code:

CGFloat allHeight= 0.0;
for(int i=0; i < [publications count]; i++) {
        Publication* pub= [publications objectAtIndex:i];
        CGFloat pubHeight= [self heightForTextStorage:[pub statusContent] withWidth:300];
    if (pubHeight < 100.0) 
        pubHeight= 100.0;
    allHeight += pubHeight;
}

if (allHeight > [[self superview] bounds].size.height) {
    NSRect allBounds= self.frame;
    allBounds.size.height= allHeight;
    [self setFrame:allBounds];
}
else {
    NSRect allBounds= [[self superview] bounds];
    [self setFrame:allBounds];
}

Thanks in advance!

Was it helpful?

Solution

Once again I found the solution. I was changing the nsview bounds inside the drawRect method (although it was before doing any drawing). I put that piece of code elsewhere and now it's perfectly working.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top