Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

New line upon return key in UITextView

Tags:

xcode

iphone

Hi How do I set return key to a new line to UITextView below? Thanks

-(BOOL)textView:(UITextView *)textView shouldChangeTextInRange:(NSRange)range replacementText:(NSString *)text {
if (range.length == 0) {
    if ([text isEqualToString:@"\n"]) {
        [textView resignFirstResponder];
        NSIndexPath *path = [NSIndexPath indexPathForRow:0 inSection:0];
        [self.tableView scrollToRowAtIndexPath:path atScrollPosition:UITableViewScrollPositionTop animated:YES];
        [self.tableView setScrollEnabled:NO];
        return NO;
    }
}

return YES;

}
like image 909
user2028990 Avatar asked Nov 13 '22 11:11

user2028990


1 Answers

You can make done button on navigation bar to hide keyBoard.

Because next button on keyBoard in UITextView will give you new line.

EDIT

Remove this line from your code, it will resigning your keyboard when you are pressing next button

[textView resignFirstResponder];
like image 80
Rajneesh071 Avatar answered Nov 15 '22 07:11

Rajneesh071