increase uitableviewcell height simultaneously increasing the inner UITextView

前端 未结 8 1560
花落未央
花落未央 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

    I would not bother with cells height using method

    (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath
    

    and rather made your view text field delegate and handle the following event in a way shown below:

    - (void) textFieldDidResize:(id)sender
    {
              [self.tableView beginUpdates];
              [self.tableView endUpdates];
    }
    

    Also make sure that you did the following:

    yourInputField.autoresizingMask = UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight;
    

    Then, the only one thing you need is to resize your text field. Your cells in tableview will adopt to the size of inner text field. Just add it as subview to cell.contentView.

提交回复
热议问题