简体   繁体   中英

How to add an UITextView in a resizable UITableviewCell

I need a text view inside of a resizable cell - the cell is resizing in real time, based on a specific timer/stopwatch. I can't simply put the text view inside the cell, because I'm resizing rows with reloadRowsAtIndexPath: every 10ms and that's causing the UITextView to resign first responder. I am trying to avoid calling becomeFirstResponder every time so what I did now was that I created an external text view and added it on top of the table view, so it basically only acts as if it was inside the cell.

Do you have any suggestions how else I could do this in a less hackish way?

Thanks, guys!

You shouldn't reload the table (contents) to resize. Just use:

[tableView beginUpdates];
[tableView endUpdates];

This will resize the cells but not reload the cells itself, so it should not resign the first repsonder.

[tableView beginUpdates]; [tableView endUpdates]; Call these methods if you want to perform operations simultaneously. beginUpdates and endUpdates should be nested properly within the codes. These are the efficient methods that has been provided to us.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM