当用户按下主页按钮时暂停键盘?
我正在开发一个应用程序,一切正常,除了一个例外,即当用户在键盘处于活动状态时按主页并再次打开我的应用程序时,视图框架边界正在更改并移出边界。我的预期结果是键盘应该暂停,或者当键盘处于非活动状态从后台返回到前台时视图应该保持在相同的位置。
我希望人们理解我的情况并尽快回复。
谢谢。
I am developing an application were everything is working fine, except one i.e. when user press on home while keyboard is in active and again opens my application the view frame bounds are changing and moving out of bounds. My expected result is keyboard should get suspended or the view should stay in the same position when it is come back from background to foreground with keyboard in-active state.
I hope people understand my scenario and reply ASAP.
Thanks.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
我已经找到了我的问题的解决方案,我希望人们可以使用我的解决方案。下面是我所做的代码,
在您的 RootViewController 文件中添加以下代码行(即当您打开应用程序时首先出现哪个视图)。
然后添加一个私有方法如下
我希望它对一些人有帮助,谢谢。
进一步帮助请参阅提到的链接,
I have found the solution to my question, i hope people can use my solution. Below is the code what I have done,
Add the below line of code in your RootViewController file (i.e. which view is coming at first when you open your APP).
And then add a private method as below
I hope it help some body,Thank u.
Further assistance please see the mentioned link,
应用程序委托中有一个方法,
当您按下主页按钮时会触发该方法。
在此方法中进行必要的更改(textField resignFirstResponder),我想它应该可以正常工作。
代码
编辑这是类中的
,您在其中让文本字段创建一个方法,然后
我也同意@valexa,您应该找到问题的根本原因
there is a method in the app delegate
this method is fired when you press the home button.
do the necessary changes(textField resignFirstResponder) in this method and it should work fine i guess.
EDIT here's the code
in the class where you have your textfield create a method
then in
also i agree with @valexa you should find the root cause of the problem
在软件开发中,解决根本原因总是比修补效果更好,在您的情况下,视图的定位存在问题,您应该解决这个问题,前景/后台循环不应影响视图定位。
In software development it is always better to address the root causes than to patch the effect, in your case there are problems with the positioning of your views and you should address that, foreground/background cycling should not affect the views positioning.