views:

49

answers:

1

I used this guide: http://developer.apple.com/mac/library/qa/qa2004/qa1346.html to implement scaling in a special view. The scaled view is the document view of an NSScrollView. The problem is that when I call -scaleUnitSquareToSize, then call -setNeedsDisplay:YES (I also tried -setNeedsDisplay:YES on the scroll view), the view (not the scroll bars, just everything inside) becomes blank. If I resize the window that contains the view, its contents reappear and display properly. But as soon as I rescale and redraw, it blanks out again. Any ideas on how to force the view to refresh properly?

Also, sorry for not providing source code, but the code is trade secret, so...

+1  A: 

sounds like the clipview's not getting updated to deal with the scale of your contentview. Try logging the documentview, clipview, and contentview's frame and bounds.

NSResponder
Well, I checked the bounds and frame values for all 3 views, and the values are no different in the two cases (invisible or visible). See http://cl.ly/1o6F for details on the bounds and frame values and the steps to reproduce. Basically, it's scale->invisible, resize->visible, unscale->invisible, rescale->visible, and after that sequence I end up with a visible view that's scaled. But all the frame and bounds values from the scaled/invisible and the scaled/visible views match. It also doesn't help sending setNeedsDisplay to all views.
jfm429
Huh... I just fixed it by calling `[[self documentView] setFrame:[[self documentView] frame]];` after scaling. Weird...
jfm429
sending '-setFrame:' is going to force everything above your view in the view hierarchy to redraw the rect enclosing the new frame and the previous frame, and that drawing will be flushed to the screen. It's not clear to me though why this wasn't already working for you. I'd recommend filing a bug report.
NSResponder