• 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: scrollPoint in NSScrollView does not scroll
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: scrollPoint in NSScrollView does not scroll


  • Subject: Re: scrollPoint in NSScrollView does not scroll
  • From: Kyle Sluder <email@hidden>
  • Date: Mon, 17 Jun 2013 08:35:23 -0700

On Mon, Jun 17, 2013, at 08:20 AM, Keary Suska wrote:
> On Jun 17, 2013, at 8:38 AM, Keary Suska wrote:
>
> >   NSScrollView* myscrollview = [[NSScrollView alloc] initWithFrame:NSMakeRect(0, 0, 200, 200)];
> >   NSClipView* myclipview = [[NSClipView alloc] initWithFrame:NSMakeRect(0, 0, 500, 400)];
> >   [myscrollview setHasVerticalScroller:YES];
> >   [myscrollview setHasHorizontalScroller:YES];
> >   [myscrollview setDocumentView:myclipview];
> >
> >   [[myscrollview documentView] scrollPoint:NSMakePoint(300.0, 300.0)];
> >
> >   [self.window.contentView addSubview:myscrollview];
>
>
> It may also be useful to mention that this code is all wrong.
> NSScrollView creates its own NSClipView, which is its contentView.
> NSClipView, AFAIK, will not function well as a standard view.

Yes, _this_ is the actual problem. It is perfectly fine to use
-scrollPoint: to scroll a view, once you've set up the scroll view
hierarchy correctly.

NSScrollView exposes its (self-created) clip view via the contentView
property. The documentView property is for _your own_ view; NSScrollView
inserts it into the clip view on your behalf.

This might have been clearer if you had used Interface Builder instead
of trying to build your scroll view in code; in that case, IB wouldn't
even show you the clip view at all.

Consider reviewing the Scroll View Programming Guide for Mac:
https://developer.apple.com/library/mac/#documentation/cocoa/Conceptual/NSScrollViewGuide/Articles/Introduction.html

--Kyle Sluder
_______________________________________________

Cocoa-dev mailing list (email@hidden)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:

This email sent to email@hidden


References: 
 >scrollPoint in NSScrollView does not scroll (From: Benjamin Rindt <email@hidden>)
 >Re: scrollPoint in NSScrollView does not scroll (From: Keary Suska <email@hidden>)
 >Re: scrollPoint in NSScrollView does not scroll (From: Keary Suska <email@hidden>)

  • Prev by Date: Rules for IBOutlet Strong/Weak References
  • Next by Date: Re: scrollPoint in NSScrollView does not scroll
  • Previous by thread: Re: scrollPoint in NSScrollView does not scroll
  • Next by thread: Re: scrollPoint in NSScrollView does not scroll
  • Index(es):
    • Date
    • Thread