In iPhone application, application is focused on textView

In my iPhone app, I placed textField and TextView as I grouped them with scrollview

Now the problem is when I call

[textField becomeBecomeFirstResponder]; 

it sets focus to textField in scrollView and makes the content area visible in scrollView respectively

But when I do the same with UItextView:

 [textView becomeBecomeFirstResponder]; 

it does not make the TextView visible in scroll mode, that is, it does not focus on textView (sets of cursors in text form, but the content area of ​​the scrollview dose is not displayed with manual scrolling)

What am I doing to focus on textView and adjust the content area accordingly in scrollview?

+4
source share
2 answers

I believe your problem here is that UITextView is UIScrollView and UITextField is UIControl.

Most likely, although I have not tested this in the code at the moment, the best way to handle this is to watch textView.isFirstResponder and when true, call [scrollView scrollRectToVisible:textView.frame animated:YES] in your UIScrollView.

+4
source

Make sure you have the textView delegate installed.

+1
source

Source: https://habr.com/ru/post/1344036/


All Articles