tranvutuan
tranvutuan

Reputation: 6109

get into a second line in uitextview, UITextView, ios

My view is containing :

first name ( UITextField )
last name  ( UITextField )
email      ( UITextField )
note       ( UITextView )

picture is following enter image description here

The codes below is used to handle when you enter a return key

- (BOOL)textFieldShouldReturn:(UITextField *)textField {    // invoked when user hits return of keyboard from a text field
    if ( textField      ==  self.firstName)
        [self.lastName becomeFirstResponder];
    else if (textField  == self.lastName)
        [self.email becomeFirstResponder];
    else if (textField  == self.email) {
        [self.note becomeFirstResponder];
    }

    return YES;

}

When I am at email field and hit next, I am landing at note but at the second line like following ( the light blue cursor is at a second line ) enter image description here

I dont get it. Should the cursor be at the first line of the note .

Any idea about this issue ?

Upvotes: 2

Views: 803

Answers (2)

vivek tankariya
vivek tankariya

Reputation: 156

write return NO when email text is return. Try this code.

- (BOOL)textFieldShouldReturn:(UITextField *)textField {    // invoked when user hits return of keyboard from a text field
    if ( textField      ==  self.firstName)
        [self.lastName becomeFirstResponder];
    else if (textField  == self.lastName)
        [self.email becomeFirstResponder];
    else if (textField  == self.email) {
        [self.note becomeFirstResponder];
        return NO; 
    }

    return YES;
}

Upvotes: 3

Master Stroke
Master Stroke

Reputation: 5128

I am still not sure whether the following peace of code works for you(sorry for that)...but give a try...

By Changing the curson location:

notetextView.editable = YES;
notetextView.selectedRange = NSMakeRange(2, 0);//i have put in as 2,you can change the location based on your requirent.

Your issue looks strange,and have upvoted your question,so that others can answer,if the above code won't work you...

Upvotes: 5

Related Questions