如何阻止UITextField响应摇动手势? [英] How to stop the UITextField from responding to the shake gesture?

查看:118
本文介绍了如何阻止UITextField响应摇动手势?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

默认情况下,如果您在 UITextField 中输入文字时摇动iPhone,则会出现一个小框,询问您是否要撤消输入。我怎样才能防止这种情况发生?我查看了 UITextField UITextFieldDelegate UITextInputTraits docs并没有发现任何与摇晃有关的内容。

By default, if you shake the iPhone while entering text in a UITextField, a little box will appear asking if you want to undo typing. How can I prevent this from happening? I looked through the UITextField, UITextFieldDelegate, and UITextInputTraits docs and found nothing relating to shaking.

据推测,我可以继承 UITextField 来忽略震动事件,但我对我不能搞砸其他事情的能力并不完全有信心。我喜欢像

Presumably I could subclass UITextField to ignore the shake event, but I'm not exactly confident in my ability to not screw other things up. I'd love something like

textField.respondsToShake = FALSE;

最好的方法是什么?

推荐答案

[UIApplication sharedApplication].applicationSupportsShakeToEdit = NO;

这篇关于如何阻止UITextField响应摇动手势?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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