On Apr 2, 2010, at 5:33 PM, James Walker wrote: > On 4/2/2010 1:47 PM, Quincey Morris wrote: >> On Apr 2, 2010, at 13:15, James Walker wrote: >> >>> I have an NSScrollView containing an NSTableView whose content is >>> managed by an NSArrayController. I have a situation where I need to >>> temporarily set the array controller's content to nil, mess with the >>> content, and then hand it back to the array controller, and I'd like to >>> preserve the scrolling position. I thought I could just get the value of >>> the NSScroller before, and set it back after, but that results in the >>> scroll bar being out of sync with the actual scrolling state of the >>> table. How can I do it? >> >> Maybe something like this (typed in Mail): >> >> clipOrigin = tableView.enclosingScrollView.contentView.bounds.origin; >> >> ... change the table then put it back again ... >> >> [tableView.enclosingScrollView.contentView scrollToPoint: clipOrigin]; >> >> This first line is kind of a guess, based on the documentation for >> 'scrollToPoint:'. > > > When I tried that, the table was in the right position, but the scroll bar > was wrong. If I do BOTH your trick and what I originally tried with the > NSScroller value, then it seems to work. Thanks.
You can manually update the scrollers position but there's a method on NSScrollView that will do it for you based on the content view's origin. - (void)reflectScrolledClipView:(NSClipView *)aClipView so, [[tableView enclosingScrollView] reflectScrolledClipView:[[tableView enclosingScrollView] contentView]] Ashley _______________________________________________ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) 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: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com