Note that there are some explanatory texts on larger screens.

plurals
  1. POFocus of cursor is not shifting to next UITextView in ios
    primarykey
    data
    text
    <p>This is my First question on <code>ios</code></p> <p>I am using two <code>UITextView</code> objects (textView1 and textView2) in a <code>View</code>, Each of them has some character limit with some following Scenario:</p> <ul> <li>Initially user can only enter into textView1.</li> <li>When the entered character limit of textView1 is over, the cursor will automatically shift to textView2.</li> <li>After building the project, If user tap the textView2 and try to write into it, Cursor must shifted to textView1 (because it is empty).</li> </ul> <p>I wrote the code and everything works fine except the third scenario, User can only enter into <code>textView1</code> but focus is still on <code>textView2</code></p> <p>Steps to reproduce:</p> <ul> <li>Build the project</li> <li>user tap the textView2 first and try to write something.</li> <li>According to written code, Focus remain in textView2 but user are writing into textView1 (see the attachment)</li> </ul> <p>Here is the snapshot:</p> <p><img src="https://i.stack.imgur.com/y1Sl3.png" alt="enter image description here"></p> <p>Here is the written code:</p> <pre><code>- (void)viewDidLoad { [super viewDidLoad]; [self.textView1 becomeFirstResponder]; } - (void)textViewDidChange:(UITextView *)textView{ NSInteger restrictedLengthForTextView1 = 110; NSInteger restrictedLengthForTextView2 = 130; NSString *temp=textView.text; if(textView == self.textView1){ if([[textView text] length] &gt; restrictedLengthForTextView1){ textView.text=[temp substringToIndex:[temp length]-1]; [textView resignFirstResponder]; [self.textView2 becomeFirstResponder]; } }else{ if([[textView text] length] &gt; restrictedLengthForTextView2){ textView.text=[temp substringToIndex:[temp length]-1]; [self.textView2 resignFirstResponder]; } }} - void()textViewDidBeginEditing:(UITextView *)textView{ NSInteger restrictedLengthForTextView1 = 110; NSLog(@"dalknwdlakwd"); if([[self.textView1 text] length] &lt; restrictedLengthForTextView1){ if(textView == self.textView2){ [self.textView2 resignFirstResponder]; [self.textView1 becomeFirstResponder]; } }} </code></pre> <p>Please help me here..</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload