ios
ios

Reputation: 6164

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 becomeBecomeFirstResponder]; 

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?

Upvotes: 4

Views: 2944

Answers (2)

GameLoading
GameLoading

Reputation: 6708

Be sure u have set textView's delegate.

Upvotes: 1

bobwaycott
bobwaycott

Reputation: 524

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.

Upvotes: 4

Related Questions