1
votes

I have got a problem setting up an NSScrollView in InterfaceBuilder (XCode 4) so that it looks good under both Snow Leopard and Lion.

I've got four NSViews that contain controls that need to be accessed when using the program. I have placed the views below one another inside the View of an NSScrollView, which should display a vertical scroll bar when the window becomes to small to display everything. (The view is a custom view which returns [customView isFlipped] == YES as the only customization.)

The NSScrollView is set to autosize vertically with the height of the program window. The custom view inside the scroll view is set to autosize horizontally with the width of the NSScrollView. The NSScrollView shows the vertical scroll bar and automatically hides it when the full content is shown.

With this configuration all works well under Snow Leopard. But when I use Lion the vertical scroll bar is not displayed on top of the custom view, but inside an opaque, grey bar on the right hand side. This does not disappear when the scroll bar is hidden, either because the window is big enough or because Lion hides the scroll bar when not being used. This looks really unprofessional, because I have got some elements which span the whole width of the custom view and now stop 15 pts from the window border. I can make this behave correctly under Lion when I set the width of the custom view to the width of the NSScrollView (+15pt for the width of one NSScroller), but then the view scrolls horizontally in Snow Leopard, if the vertical scroll bar is displayed. Is there any way to get it to look right with both systems?

I am compiling with the Snow Leopard 10.6 SDK and Leopard 10.5 as a minimum OS.

1

1 Answers

2
votes

You can check your [NSScroller class]'s preferredScrollerStyle and if it's not zero (actually NSScrollerStyleLegacy but you don't have it in SDK 10.6) then increase your view as you mentioned above. Also don't forget to check if your scroller class responds to that selector (and call it with performSelector:) since it was added only in SDK 10.7. Or you can use your custom descendant of NSScroller that overloads isCompatibleWithOverlayScrollers to return false. Than you'll have legacy scrollers with 15pt width even on Lion.