UITableView won't scroll after editing view frame and origin

后端 未结 1 1272
余生分开走
余生分开走 2021-01-28 08:21

I\'m trying to implement a UITextView in a table cell at the bottom of a table view.

I\'ve tried the suggestions here Making a UITableView scroll when text field is sele

相关标签:
1条回答
  • 2021-01-28 08:22

    I was able to solve my problem of the locked scrolling by removing the code that edits the view's origin. In addition, I implemented scrolling to the bottom cell by using the tableview's contentSize property in my calculations.

    -(void) keyboardWillShow:(NSNotification *)note
    {
    
      if(!isKeyboardShowing)
        {
        isKeyboardShowing = YES;
        CGRect keyboardBounds;
        [[note.userInfo valueForKey:UIKeyboardBoundsUserInfoKey] getValue: &keyboardBounds];
        CGFloat keyboardHeight = keyboardBounds.size.height;
    
                CGRect frame = self.view.frame;
                frame.size.height += keyboardHeight;
                self.view.frame = frame;
    
        CGPoint scrollPoint = frame.origin;
        scrollPoint.y += _tableView.contentSize.height - keyboardHeight;
        [_tableView setContentOffset:scrollPoint animated:YES];
        }
    }
    
    0 讨论(0)
提交回复
热议问题