UITextField -resignFirstResponder 失败

发布于 2024-12-11 04:17:34 字数 518 浏览 2 评论 0原文

我最近更新了 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 技术交流群。

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

发布评论

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

评论(1

呢古 2024-12-18 04:17:34

不确定这是否有任何帮助,但第二个示例中的逻辑正确吗?

第一个看起来像是您正在检查哪个 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'

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