views:

305

answers:

1

I have a view composed of a UIScrollView which contains a UITextField, a UILabel and a UITextView. I want to configure the view such that when the user types text into the textview, the scrollview will scroll to keep the line being typed visible.

A: 

In the -[UITextViewDelegate textView:shouldChangeTextInRange:replacementText:] you will need to monitor the amount of text displayed and calculate whether that has scrolled of the screen. Then adjust the scrollview's setContentOffset:animated: accordingly.

However, the best option is not to try and edit within the scroll view at all. Instead, use a separate detail view to edit the text in and just use the more complicated scroll view to display the text. In other words, think of the scrollview as a table and the textview as a row in the table. You select the textview and it opens a detail view just like it would in a table.

Remember that your users expect hierarchy on an iPhone. Sliding over to another screen to enter text is a very common UI behavior and it won't disorient them. They will appreciate the greater ease of using a view that does nothing but enter the text.

See this question from the sidebar: http://stackoverflow.com/questions/1088960/iphone-auto-scroll-uitextview-but-allow-manual-scrolling-also

TechZen
Can u give me any example of it?I need zp file which can i downlao and run and understand it?
I'll see if I have something bookmarked or laying around. Check back later today.
TechZen