UITextField -resignFirstResponder 失败
我最近更新了 XCode(4.2,带有 iOS5 SDK),现在每次我使用“resignFirstResponder”时,我的应用程序都会抛出 EXC_BAD_ACCESS。
我熟悉内存管理,并检查之前没有释放任何内容......疯狂的部分是“becomeFisrtResponder”可以工作。
工作正常:
if(_TextField==input){
[inputPassWord becomeFirstResponder];
}
else
{
[input becomeFirstResponder];
}
失败:
if(_TextField==input){
[inputPassWord becomeFirstResponder];
}
else
{
[_TextField resignFirstResponder];
}
知道可能是什么吗?
谢谢!
I recently updated XCode (4.2 with iOS5 SDK) and now my app is throwing EXC_BAD_ACCESS everytime i use "resignFirstResponder".
I'm familiar with memory management and check out that nothing was released before... The crazy part is that "becomeFisrtResponder" would work.
Working fine:
if(_TextField==input){
[inputPassWord becomeFirstResponder];
}
else
{
[input becomeFirstResponder];
}
Failing:
if(_TextField==input){
[inputPassWord becomeFirstResponder];
}
else
{
[_TextField resignFirstResponder];
}
Any idea of what it could be?
Thanks!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
不确定这是否有任何帮助,但第二个示例中的逻辑正确吗?
第一个看起来像是您正在检查哪个 TextField 已完成某些操作,然后在另一个 TextField 上设置 firstResponder 。
第二个似乎什么也没做,因为如果输入不是正在测试的文本字段,它只会调用
[input resignFirstResponder]
。您是否尝试过切换第二个示例中的两行代码,或者使用
!=
而不是==
。也许值得一试。我认为这不会引起你的问题,但我对此还很陌生'
Not sure if this is going to be of any help but is the logic in the second example right?
The first one looks like you're checking to see which TextField has done something and then setting firstResponder on the other.
The second one seems to do nothing since it's only calling
[input resignFirstResponder]
if Input is NOT the textField being tested.Have you tried switching the two lines of code in the second example, or using
!=
instead of==
. Might be worth a try.I don't think that should cause your problem though but I'm pretty new to this'