user2037857
user2037857

Reputation: 83

duplicate UITextView scroll position

I have two UITextView, where I insert some text in some time. My textview's is same of frame When text is more of my frame I want to automatically scroll down, that user see last text on my textView's, and when user scroll up or down my textView's - scroll position is duplicate for left or right my textView's.

How I can do that?

update (automatically scroll down) solution

[textLeft scrollRangeToVisible:NSMakeRange([textLeft.text length], 0)];
[textRight scrollRangeToVisible:NSMakeRange([textRight.text length], 0)];

Upvotes: 1

Views: 320

Answers (1)

user2037857
user2037857

Reputation: 83

need implement <UITextViewDelegate>

textLeft.delegate = self;
textRight.delegate = self;


- (void)scrollViewDidScroll:(UIScrollView *)scrollView
{
    CGPoint scrollPointL = textLeft.contentOffset;
    CGPoint scrollPointR = textRight.contentOffset;

    if (textRight.dragging) {
    [textLeft setContentOffset:scrollPointR animated:NO];
    }

    if (textLeft.dragging) {
         [textRight setContentOffset:scrollPointL animated:NO];
    }
}

Upvotes: 1

Related Questions