danielamitay/DAKeyboardControl

Panning up and down calculates wrong height

Closed this issue · 0 comments

Pan down the keyboard half way and then pan up the keyboard again. This will cause the UITextView height to be wrong.

- (void)viewDidLoad
{
    [super viewDidLoad];

    CGRect frame = self.view.bounds;
    self.textView = [[UITextView alloc] initWithFrame:frame];
    self.textView.keyboardAppearance = UIKeyboardAppearanceDark;
    [self.view addSubview:self.textView];

    __weak typeof(self) weakSelf = self;

    [self.textView addKeyboardPanningWithFrameBasedActionHandler:^(CGRect keyboardFrameInView, BOOL opening, BOOL closing) {
        CGRect textViewFrame = weakSelf.textView.frame;
        textViewFrame.size.height = keyboardFrameInView.origin.y;
        weakSelf.textView.frame = textViewFrame;
    } constraintBasedActionHandler:nil];
}