Re: Keeping Scroll Views in Sync
Re: Keeping Scroll Views in Sync
- Subject: Re: Keeping Scroll Views in Sync
- From: Dave <email@hidden>
- Date: Wed, 09 Oct 2013 18:22:05 +0100
Hi,
I should have said, this is for iOS and it doesn't look like UIScrollView has the scrollToPoint method defined.
There is also something about using notifications for this in a Mac Reference:
https://developer.apple.com/library/mac/documentation/Cocoa/Conceptual/NSScrollViewGuide/Articles/SynchroScroll.html
But I'm not sure if this is recommended for iOS?
Thanks a lot
Dave
On 9 Oct 2013, at 14:52, Tamas Nagy <email@hidden> wrote:
> Hi,
>
> in one of my apps I'm doing this too, but without any problems. I'm using scrollToPoint: method instead.
>
> [[NSNotificationCenter defaultCenter] addObserver:self
> selector:@selector(viewScrolled:)
> name:NSViewBoundsDidChangeNotification
> object:[[self timelineViewScrollView] contentView]];
>
> …
>
>
> -(void)viewScrolled:(NSNotification *)notification {
>
>
> if ([[notification object] isEqualTo:[[self timelineViewScrollView] contentView]]) {
>
>
> [[[self trackHelperViewScrollView] contentView] scrollToPoint:NSMakePoint([[[self trackHelperViewScrollView] contentView] bounds].origin.x, [[[self timelineViewScrollView] contentView] bounds].origin.y)];
>
> [[[self markerViewScrollView] contentView] scrollToPoint:NSMakePoint([[[self timelineViewScrollView] contentView] bounds].origin.x, [[[self markerViewScrollView] contentView] bounds].origin.y)];
>
>
> } else
>
> .
> .
> .
> .
>
> Cheers,
> Tamas
>
> On Oct 9, 2013, at 3:44 PM, Dave <email@hidden> wrote:
>
>> Hi,
>>
>> I've got a number of scroll views (A, B and C) I'm trying to keep in sync with each other, e.g. if the user scrolls A then I want B and C to scroll in sync with it. I've got this working by adding code in the scrollViewDidScroll method that passes the contentOffset onto the other two scroll views.
>>
>> This works ok, but it is judders a bit and flickers when scrolling quickly.
>>
>> This is the code:
>>
>> - (void) scrollViewDidScroll:(LTWScrollView*) theScrollView
>> {
>> if (theScrollView.tag == kScrollViewA)
>> {
>> self.scrollViewB.contentOffset = theScrollView.contentOffset;
>> self.scrollViewC.contentOffset = theScrollView.contentOffset;
>> }
>>
>> else if (theScrollView.tag == kScrollViewB)
>> {
>> self.scrollViewA.contentOffset = theScrollView.contentOffset;
>> self.scrollViewC.contentOffset = theScrollView.contentOffset;
>> }
>> else if (theScrollView.tag == kScrollViewC)
>> {
>> self.scrollViewA.contentOffset = theScrollView.contentOffset;
>> self.scrollViewB.contentOffset = theScrollView.contentOffset;
>> }
>> }
>>
>> I've tried a few things, but nothing seem to make a difference.
>>
>> Any ideas anyone?
>>
>> Thanks a lot
>> Dave
>>
>>
>> _______________________________________________
>>
>> 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
>
_______________________________________________
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