UITextView cursor below frame when changing frame

前端 未结 9 477
名媛妹妹
名媛妹妹 2020-12-01 06:50

I have a UIViewCOntrollerthat contains a UITextView. When the keyboard appears I resize it like this:

#pragma mark - Responding to          


        
9条回答
  •  隐瞒了意图╮
    2020-12-01 07:24

    Angel Naydenov's comment above is right, especially in cases such as switching from English to Japanese keyboard that shows suggests.

    When switching keyboards, UIKeyboardWillShowNotification is called but UIKeyboardWillHideNotification is not called.

    So you must adjust the inset to use the absolute value and not use +=.

    Unrelatedly, [self.textView setContentOffset:newOffset animated:YES]; will not actually change the graphics in iOS 7.1 after the keyboard is shown for the second time, which is probably a bug. A workaround I used is replacing

    [self.textView setContentOffset:newOffset animated:YES]; 
    

    with

    [UIView animateWithDuration:.25 animations:^{
            self.textView.contentOffset = newOffset;
     }];
    

提交回复
热议问题