• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: NSImageView scrolling
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: NSImageView scrolling


  • Subject: Re: NSImageView scrolling
  • From: Jeremy Dronfield <email@hidden>
  • Date: Sat, 28 Sep 2002 12:04:28 +0100

On Saturday, September 28, 2002, at 05:35 am, Jan Van Tol wrote:

Hello list,

I need to have an NSScrollView with an NSImageView inside it, which I know how to do already. What I don't know is how to get the imageView to expand automatically to show the entire NSImage it displays. When the NSImageView grows larger than the scroll view, scrollbars should appear.

Is this possible? How would I go about doing it?

It's not clear what you want: do you want the whole view to expand to display the whole image, or simply to bring up scrollbars when the image is too large? I'll assume the latter. The default implementation of NSScrollView has no scrollbars. This makes sense, because you only want them if the image is too large. What you need to do is check the image size when it loads, and give the scroll view scrollbars accordingly, something like this:

NSSize selfSize = [myImageView frame].size;
NSSize sViewSize = [myScrollView frame].size;

BOOL hFlag = selfSize.width > sViewSize.width;
BOOL vFlag = selfSize.height > sViewSize.height;

[scrollView setHasHorizontalScroller:hFlag];
[scrollView setHasVerticalScroller:vFlag];

Also, you need to read the documentation on NSImage, NSScrollView, NSView, NSImageView etc and related Programming Topics.
-Jeremy

========================================
email@hidden // email@hidden
The Alchemy Pages:
- fractious fiction at http://freespace.virgin.net/jeremy.dronfield
========================================
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives: http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.

  • Follow-Ups:
    • Re: NSImageView scrolling
      • From: Marco Binder <email@hidden>
References: 
 >NSImageView scrolling (From: Jan Van Tol <email@hidden>)

  • Prev by Date: Re: Why am I getting this error?
  • Next by Date: Re: nil messaging? Is it safe?
  • Previous by thread: NSImageView scrolling
  • Next by thread: Re: NSImageView scrolling
  • Index(es):
    • Date
    • Thread