in iPhone App set focus on textView
In my iPhone App I have put textField and TextView both and I have grouped them with scrollview
now the problem is when I call
[textField becomeBeco开发者_C百科meFirstResponder];
it sets focus on textField in scrollView and makes content Area visible in scrollView accordingly
But When I do same thing with UItextView:
[textView becomeBecomeFirstResponder];
it does not make TextView visible in scroll view i.e it does not focus on textView (cursor sets on text view but content area of scrollview dose not appear with out manual scrolling)
What shoud I do to set focus on textView and set content area accordingly in in scrollview?
I believe your trouble here is that UITextView is a UIScrollView, while UITextField is a UIControl.
It is quite likely, though I have not tested this in code at the moment, that the best way to handle this is to watch for textView.isFirstResponder
and when true, call [scrollView scrollRectToVisible:textView.frame animated:YES]
on your UIScrollView.
Be sure u have set textView's delegate.
精彩评论