Keyboard in the way of text fields, how to move up

I am using the Xcode SplitView template.

I placed a bunch of text fields on the side of the part, but I forgot that the keyboard is half the screen.

How to move this detailed view up when the keyboard appears on the screen?

+3
source share
2 answers

I used this solution from the always useful Cocoa With Love , when I could not use UIScrollView.

If you want to add a UIScrollView to your hierarchy, this is even easier. Just insert a UIScrollview into the hierarchy above the text fields and use this code when the user clicks a text element to start editing:

UIScrollView* v = (UIScrollView*) self.view ;
CGRect rc = [textField bounds];
    rc = [textField convertRect:rc toView:v];
rc.origin.x = 0 ;
rc.origin.y -= 60 ;

rc.size.height = 400;

[self.scroll scrollRectToVisible:rc animated:YES];

Good luck

+3
source

. , , , - textViewDidBeginEditing scrollToRowAtIndexPath :

- (void)textViewDidBeginEditing:(UITextView *)textView{
    UITableViewCell *cell = (UITableViewCell*) [[textView superview] superview];    
    [self.myTableView scrollToRowAtIndexPath:[self.myTableView indexPathForCell:cell] atScrollPosition:UITableViewScrollPositionMiddle animated:YES];
}

, , , , , , , @MystikSpiral.

+1

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


All Articles