Hello,

I've the following situation: I have 3 UIScrollViews in an app. The first is 
like a table (centerTable). The second a row (firstRow) and the last a column 
(firstColumn). The column must scroll only in vertical, the row only in 
horizontal and the table in any direction. And the movement must be 
synchronized between then. So, for example, if I scroll the table, the row and 
the column scrolls with the same offset.

Using KVO, I added the row and the column as observers of the contentOffset 
from table:

        [centerTable addObserver:firstColumn 
forKeyPath:@"contentOffset"options:NSKeyValueObservingOptionNew context:NULL];
        [centerTable addObserver:firstRow 
forKeyPath:@"contentOffset"options:NSKeyValueObservingOptionNew context:NULL];

And added in classes from row/column the method:

- (void)observeValueForKeyPath:(NSString *)keyPath ofObject:(id)object 
change:(NSDictionary*)change context:(void *)context {
    if ([keyPath isEqualToString:@"contentOffset"]) {
        CGPoint newContentOffset = [(UIScrollView *)object contentOffset];
        newContentOffset.y = self.contentOffset.y;
        self.contentOffset = newContentOffset;
    }
}

With this is almost OK, and the row/cloumn moves acordingly as table scrolls. 
But after I add the table as observer of contentOffset from row/column with:
Isso está funcionando belezinha. Mas ao adicionar a tabela como observadora da 
propriedade contentOffset da linha/coluna:

        [firstColumn addObserver:centerTable 
forKeyPath:@"contentOffset"options:NSKeyValueObservingOptionNew context:NULL];
        [firstRow  addObserver:centerTable 
forKeyPath:@"contentOffset"options:NSKeyValueObservingOptionNew context:NULL];

and implement observeValueForKeyPath:ofObject:change:context: in table class, 
whenever I try to scroll any of the UIScrollView, the program abort. I think 
that I made a loop, and when I update one of the contenOffset, the other views 
receive the message, update it self contentOffset and send the message for the 
others...

Has someone a sugestion of how to solve this?

Thank you

Tales Pinheiro_______________________________________________

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

Reply via email to