• 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: NSScrollView and Custom Views
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: NSScrollView and Custom Views


  • Subject: Re: NSScrollView and Custom Views
  • From: Joshua Scott Emmons <email@hidden>
  • Date: Mon, 27 Jun 2005 09:34:40 -0400

Anyone have any ideas? Am I way off course?

Can't say if you're off course or not, but I've never been able to get my custom view out of the lower-left corner (or upper-left if I've overridden -isFlipped to return YES) when working with a scroll view.


But, truth be told, you really don't need it to be moved anywhere else. You should be thinking of that view as the piece of paper that you will draw all of your other stuff on. The only thing it needs to worry about is resizing itself so that whatever it contains is displayed. When you think of it that way, it doesn't make much sense to have this:

+---------------+
|               |
|   +------+    |
|   | text |    |
|   +------+    |
|               |
+---------------+

Because if the view gets too big, it'll look like this:

+---------------+ ^
|               | *
|   +-----------| |
|   | text is cu| |
|   | off at odd| |
|   | because   | |
+---------------+ v
<=-------------->

The user will scroll so that the document fits:

+--------------+ ^
|+------------+| |
|| text is cut|| *
|| off at odd || |
|| because of || |
|+------------+| |
+--------------+ v
<---=----------->

So now everything looks as it should, but the scroll bars are still there, and their thumbs are at wonky positions because of that big margin you have in the upper left.

A better solution is to size your custom view (the paper) to be the same size as the scroll view that contains it, and then center the thing you want to display in the custom view. Then you can resize your custom view as its contents grows and the scroll view will Do The Right Thing.


Cheers, -Joshua Emmons _______________________________________________ Do not post admin requests to the list. They will be ignored. Cocoa-dev mailing list (email@hidden) Help/Unsubscribe/Update your Subscription: This email sent to email@hidden
  • Follow-Ups:
    • Re: NSScrollView and Custom Views
      • From: James Housley <email@hidden>
References: 
 >NSScrollView and Custom Views (From: email@hidden)

  • Prev by Date: Re: Moving other application windows
  • Next by Date: Re: How to find the manual (or at least the header)
  • Previous by thread: NSScrollView and Custom Views
  • Next by thread: Re: NSScrollView and Custom Views
  • Index(es):
    • Date
    • Thread