Note that there are some explanatory texts on larger screens.

plurals
  1. POScrolling UITextView programmatically
    text
    copied!<p>I'm implementing some simple text chatting capabilities in my app and I'm having issues with scrolling the <code>UITextView</code> programmatically. I'm using a <code>UITextView</code> created in Interface Builder that appends a new line and some text to the preexisting text. When the new text is added it should scroll to the bottom.</p> <p>I built a test application to nail down the concept before adding it to my app. The text in the <code>UITextView</code> updates with the text from a <code>UITextField</code>, however no scrolling occurs.</p> <pre><code>- (IBAction)enteredText { CGPoint currentPosition = [textWindow contentOffset]; [textWindow setText:[NSString stringWithFormat:@"%@\n%@", textWindow.text, textInput.text]]; [textWindow setContentOffset:currentPosition animated:NO]; [textWindow scrollRangeToVisible:NSMakeRange([textWindow.text length], 0)]; [textInput setText:@""]; [textInput becomeFirstResponder]; </code></pre> <p>}</p> <p>I remember implementing a very similar feature in another application I developed a while ago andfrom what I remember the code is similar. The only difference is that the earlier application was for iPhone OS 2 but this one is for 3.0. I read in some forums that the 3.0 beta had some issues with scrolling when the <code>UITextView</code> was created in Interface Builder. I checked the <a href="http://developer.apple.com/iphone/library/releasenotes/General/RN-iPhoneSDK-3/index.html" rel="nofollow noreferrer">current release notes</a> and I didn't see anything indicating that.</p> <p><strong>Edit:</strong> The IB action is called because text is updated in the UITextView. And "Cancellable Content Touches" is checked.</p> <p><strong>Edit:</strong> Confirmed that the same code works on 2.2.1 but not 3.0</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload