Re: Scrolling NSView without scrollbars
Re: Scrolling NSView without scrollbars
- Subject: Re: Scrolling NSView without scrollbars
- From: Brian Webster <email@hidden>
- Date: Thu, 3 Jan 2002 12:25:07 -0600
On Thursday, January 3, 2002, at 10:14 AM, cocoa-dev-
email@hidden wrote:
I need to be able to store a large image in an NSView, so that I can
display different sections of the image programmatically and therefore
continuously scroll the contents of the view. When reading the NSView
documentation, it suggests that the NSView frame and bound
sizes can be
different, so that a large image can be placed in a smaller NSView.
However, Interface Builder enforces the same size for the frame and
bounds, preventing me from making the image larger than the visible
region of the view.
As a Cocoa newbie, I assume I'm just overlooking something incredibly
simple. I'd appreciate some help.
Try doing this:
1. Drag your view into a window in IB.
2. Select the view, go to the Layout menu and select "Make
subviews of"->"Scroll view".
3. Go to the attributes inspector for the scroll view and turn
off both scroll bars.
4. Double click on the scroll view, which will select the view
it is enclosing. Then go to the size inspector (command-3) and
set the width and height of your view as you wish.
You can then programatically scroll the image view inside the
scroll view by sending it a scrollPoint: or scrollRectToVisible:
message.
--
Brian Webster
email@hidden
http://homepage.mac.com/bwebster