danielamitay / DAKeyboardControl

DAKeyboardControl adds keyboard awareness and scrolling dismissal (ala iMessages app) to any view with only 1 line of code.
Other
1.58k stars 214 forks source link

Panning up and down calculates wrong height #69

Closed vikfroberg closed 5 years ago

vikfroberg commented 10 years ago

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];
}