1

I am printing debug text to my applications text view with

- (void) updateDebugWindow:(NSString *)text {
[dbgText setText:[NSString stringWithFormat:@"%@%@\r\n",dbgText.text,text]];
}

As you can see, the next line will append to the previous so that I can see what happened in the previous step. This works fine

[self updateDebugWindow:@"Debug info"];

but when it reaches bottom it does not automatically scroll down to show the next line of text, I have to manually scroll it with my finger.

Is there some option in xcode which let the text view automatically follow the text?

2 Answers 2

2

Here is your routine re-written:

- (void) updateDebugWindow:(NSString *)text {  
    [dbgText setText:[NSString stringWithFormat:@"%@%@\r\n",dbgText.text,text]];  
    [dbgText scrollRangeToVisible:NSMakeRange([dbgText .text length], 0)];
}

This adds your text, then scrolls to the last "character" in the overall string.

Sign up to request clarification or add additional context in comments.

1 Comment

@Wilhelmsen - Not a problem whatsoever :-)
1

Try this

NSRange selectedRange = dbgText.selectedRange;
[self updateDebugWindow:@"Debug info"];
dbgText.selectedRange = selectedRange;
dbgText.scrollEnabled = YES;

Hope it will work.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.