2
votes

I'm developing a small OS X app which consists of two NSTextView objects and each of them wrapped by a NSScrollView.

I followed the steps mentioned in the Apple Mac Developer Library (https://developer.apple.com/library/mac/documentation/Cocoa/Conceptual/NSScrollViewGuide/Articles/SynchroScroll.html)

It seems to work... well, at least when the user scrolls manually by performing usual scrolling gestures. But the synchronous scrolling doesn't seem to work when the user enters a lot of text in the NSTextView which causes the ScrollView to scroll down.

The synchronized (and therefore listening) scroll view scrolls down for a short moment and then jumps back to the top of the text view.

Does anybody have a clue why this might happen?

1
A quick test works (OS X 10.10). What did you change? Which text is taller? - Willeke
No text is taller. The second (synchronized) TextView just scrolls back to the top when I add a new line into the first TextView - Alex

1 Answers

0
votes

I found a solution.

The issue seems to occur when the string value of the TextView (that is located within the synchronized ScrollView) is being changed programmatically.

I've added a call like [self synchronizedViewContentBoundsDidChange:nil]; as soon as I've changed the string value and this works.

When I now add new lines to the original text view which causes the scroll view to scroll down the synchronized scroll view scrolls correctly.