UICatalog 和键盘事件

发布于 2024-08-24 07:08:35 字数 359 浏览 7 评论 0原文

Apple 的 UICatalog 示例应用程序 的最新版本包括零代码TextFieldController 用于处理键盘显示/隐藏事件,但表格视图仍然可以随着键盘完美地上下滑动。

有谁知道新的技巧是什么吗? XIB 中是否有设置允许他们放弃注册通知或使用 TextField 委托方法?

TextViewController 仍然使用键盘通知来处理视图滑动,所以我真的很困惑为什么 TextFields 不再包含它。

想法?

The latest version of Apple's UICatalog example application includes zero code in the TextFieldController for handling keyboard show/hide events, and yet the table view still slides up and down beautifully with the keyboard.

Does anyone know what the new trick is? Are there settings in the XIB that allowed them to forgo registering for the notifications or using TextField delegate methods?

The TextViewController still uses keyboard notifications to deal with view sliding, so I'm really confused as to why this isn't included for TextFields anymore.

Thoughts?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

如此安好 2024-08-31 07:08:35

如果键盘已打开,您可以通过调用以下命令关闭键盘:

[sender resignFirstResponder];

但是不确定是否打开键盘。

You can close the keyboard, if it's open by calling:

[sender resignFirstResponder];

Not sure about opening the keyboard however.

甜中书 2024-08-31 07:08:35

这个技巧隐藏在对可滚动视图中的 UITextField 调用 becomeFirstResponder 中。显然,每当调用 [textFieldBecomeFirstResponder] 时,iOS 都会自动滚动父视图,直到所述 textField 可见。

在某些情况下,这种行为实际上是不受欢迎的,因为如果您尝试这样做,它通常不会滚动到 UIScrollView 方法 scrollRectToVisible:animated: 会滚​​动到的位置事情就是这样。

谢谢大家的想法!

The trick is hidden within calling becomeFirstResponder on a UITextField that is in a scrollable view. Apparently, whenever calling [textField becomeFirstResponder], iOS automatically scrolls the parent view until said textField is visible.

This behavior can actually be undesirable in some cases, as it will not usually scroll to the same location that the UIScrollView method scrollRectToVisible:animated: would if you were to try to do things that way.

Thanks for your thoughts everyone!

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文