在不关闭键盘的情况下更改UITableView行高 [英] Change UITableView row height without dismissing keyboard

查看:179
本文介绍了在不关闭键盘的情况下更改UITableView行高的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在UITableViewCell中有一个TextView。 TextView中的文本可以就地编辑。

I have a TextView inside a UITableViewCell. The text inside the TextView can be edited right there in place.

TextView根据文本包含的行数垂直增长和缩小。到目前为止,我还没有发现让包含TextView的行动态增长和缩小的可能性。

The TextView grows and shrinks vertically depending on the number of lines the text contains. So far I haven't found a possibility to also let the row containing the TextView grow and shrink dynamically.

[tableView reloadData];

[tableView reloadRowsAtIndexPaths: withRowAnimation:];

不起作用,因为他们在每次更改时都会关闭键盘。

don't work, because they dismiss the keyboard on every change.

有没有办法在不关闭键盘的情况下更改UITableView中单个行的高度?

Is there a way to change height of an individual row in a UITableView without dismissing keyboard?

推荐答案

是的,您可以在键入时调整行高。它没有记录,它无视原因,但您需要做的就是在tableView.rowHeight中设置新值(或者让heightForRowAtIndexPath准备好计算新的高度),然后执行以下操作:

Yes, you can have the row heights adjust as you type. It's not documented, and it defies reason, but all you need to do is set the new value in tableView.rowHeight (or have heightForRowAtIndexPath:ready to compute the new heights), then do this:

[tableView beginUpdates]; // updates the row heights ...
[tableView endUpdates]; // ... nothing needed in between

这篇关于在不关闭键盘的情况下更改UITableView行高的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆