在重新加载 UITableView 部分时保持 UIKeyboard [英] Keep UIKeyboard up while reloading UITableView section

查看:51
本文介绍了在重新加载 UITableView 部分时保持 UIKeyboard的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想知道是否有办法在重新加载 UITableView 中的部分时保持 UIKeyboard 正常运行?我在 UITableViewsectionheader view 中有 UITextField.输入此 UITextField 会触发需要更新(重新加载)部分 的操作.

I would like to know if there is a way to keep UIKeyboard up while reloading section in UITableView? I have UITextField inside a header view of UITableView's section. Typing into this UITextField fires action that requires a section to be updated (reloaded).

由于调用 [tableView reloadSections:...],键盘会隐藏自己,因为 UITextField 失去了它的 firstResponder 状态.

As a result of calling [tableView reloadSections:...] the keyboard hides itself, because UITextField loses it's firstResponder status.

我想达到类似在 UITableView 中使用 UISearchBar 组件时的效果.

I would like to achieve similar effect like when using UISearchBar component in UITableView.

谢谢!

推荐答案

如果你重新加载,一切都会得到刷新.发生这种情况时,当前的第一响应者会辞职,键盘会被动画化.为避免这种情况,您无需重新加载...

If you reload, everything will get refreshed. When that happens, the current first responder is resigned and the keyboard is animated out. To avoid that you need to no reload...

您需要直接更新可见单元格并使用 insertRowsAtIndexPaths:withRowAnimation:deleteRowsAtIndexPaths:withRowAnimation: 更改表管理的行数.这样就不会重新加载该部分,并且您将避免任何单元格动画/刷新视图.

You would need to update the visible cells directly and use insertRowsAtIndexPaths:withRowAnimation: and deleteRowsAtIndexPaths:withRowAnimation: to make changes to the number of rows the table is managing. In this way the section won't be reloaded and you will avoid any cell animations / refreshing of views.

这篇关于在重新加载 UITableView 部分时保持 UIKeyboard的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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