应用程序在编辑自定义UITextField后冻结 [英] Application freezes after editing custom UITextField

查看:66
本文介绍了应用程序在编辑自定义UITextField后冻结的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个自定义 UITextField 用于验证非空输入,正确的电子邮件,大于x字符的密码等。

I have a custom UITextField used for validating for non empty input, correct emails, passwords bigger than x characters etc.

UITextField 有一个自己的委托,因为我对文本字段对象本身进行了所有验证。不确定这是不是问题。

The UITextField has a delegate to itself, since I do all the validation on the text field object itself. Not sure if this is the problem.

此自定义 UITextField 是在.XIB文件中创建的。

This custom UITextField is created in the .XIB file.

文本字段有时会在编辑文本字段时锁定应用程序。当我按下键盘上的下一步按钮时(通常转到需要填写的下一个文本字段),它通常也会锁定。

The text field sometimes locks the application when editing the text field itself. It also usually locks up when I press the "Next" button on the keyboard (for going to the next text field that needs to be filled).

Xcode没有给出一个错误(例如循环错误,我假设它是),应用程序只是锁定。这不会一直发生,但通常情况下,如果我用文字强调测试它,然后按下一步,它可能会锁定。

Xcode doesn't give back an error (such as a loop-error, which I was assuming it was), the application just locks up. This doesn't happen all the time, but usually, if I stress test it with text, then press "Next", it's likely to lock up.

应用程序没有不会崩溃......它不会回到主屏幕,但它确实只是锁定,并且没有响应。

The app doesn't crash...it doesn't go back to the main screen, but it really just locks up, and stays unresponsive.

有什么想法吗?如果您需要更多信息来解决这个问题,请与我们联系。我现在很茫然。

Any ideas? Let me know if you need more info to figure this out. I'm at a loss at the moment.

编辑:解决了,显然它不是一个好主意是将UITextField的委托设置为自己。我最终做的是创建一个单独的类,专门作为 UITextField 的委托处理并执行该类中的所有逻辑。该类还有一个属性连接到它是委托的文本字段。

edit: Solved, apparently it's not a good idea to set a UITextField's delegate to itself. What I ended up doing is creating a separate class that deals specifically as being the delegate for the UITextField and doing all the logic in that class. That class would also have a property connected to the text field it is a delegate for.

推荐答案

我也会写答案这里:

显然,将UITextField的委托设置为自身并不是一个好主意,因为它最终会进入循环。

Apparently it's not a good idea to set a UITextField's delegate to itself, because it can end up going into a loop.

我最终做的是创建一个单独的类,专门处理UITextField的委托并执行该类中的所有逻辑。该类还有一个属性连接到它是委托的文本字段。

What I ended up doing is creating a separate class that deals specifically as being the delegate for the UITextField and doing all the logic in that class. That class would also have a property connected to the text field it is a delegate for.

这篇关于应用程序在编辑自定义UITextField后冻结的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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