increase uitableviewcell height simultaneously increasing the inner UITextView

前端 未结 8 1568
花落未央
花落未央 2021-02-02 17:13

I create a UITableView with different types of UITableViewCell depending on the type of content to display. One of this is a UITableViewCell

8条回答
  •  佛祖请我去吃肉
    2021-02-02 17:29

    - (void)textViewDidChange:(UITextView *)textView
    {
        UITableViewCell *cell = (UITableViewCell*)textView.superview.superview;
    
        if (cell.frame.size.height < textView.contentSize.height) {
            [self.tableView beginUpdates];
            CGRect frame = textView.frame;
            frame.size.height = textView.contentSize.height;
            textView.frame = frame;
            CGRect cellFrame = cell.frame;
            cellFrame.size.height = textView.frame.size.height;
            cell.frame = cellFrame;
            [self.tableView endUpdates];
        }
    
    }
    

提交回复
热议问题