iphone - Scrolling UITextView programmatically -
I am implementing some simple text chat capabilities in my app and give me the UITextView
programmatic form I have created a UITextView
in the interface builder that adds a new line and some text to the already existing text. When the new text is added, it should scroll down to the bottom.
Before creating my app I had created a test application to dismiss the concept. Text in the UITextView
update with text from UITextFiew
, however there is no scrolling.
- (IBAction) entered text {CGPoint currentPosition = [TextWindow content offset]; [TextWindow Set Text: [NSString stringWithFormat: @ "% @ \ n% @", Text Window.text, textInput.text]]; [Text window offset offset content: animated current status]; [Text Window Scroll Range Visibility: NSMKrange ([TextWindows Text Length], 0)]; [Text input set text: @ ""]; [Become TextInput First Responder];
}
I remember that implementing a similar feature in another application which I had developed some time ago and which also reminds me of the code Is the way. The only difference is that the earlier application was for the iPhone OS 2, but it is for 3.0. I have read in some forums that there were some problems with scrolling 3.0 beta when the UITextView
was built in the interface builder. I checked and I did not see anything that indicates.
Edit: The operation of the IB is called because the text is updated in UITQtview.
Edit: Confirms that the same code works on 2.2.1, but not 3.0
I came to know that the user has started scrolling after taping on the UITSweepv. So after I loaded this particular scene, I temporarily set the utviewview as FirstSponder, then the UTTFESTField as FirstSponder:
[myChatRoomViewController.chatWindow beFirstResponder]; [MyChatRoomViewController.input becoming First Responder];
Scrolling came automatically, though it seemed less smoother than what I missed in the iPhone OS 2.
Comments
Post a Comment