为什么不解雇WithClickedButtonIndex曾经调用过clickedButtonAtIndex? [英] Why doesn't dismissWithClickedButtonIndex ever call clickedButtonAtIndex?

查看:173
本文介绍了为什么不解雇WithClickedButtonIndex曾经调用过clickedButtonAtIndex?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

http://iphonedevelopment.blogspot.com/2009/02/alert-view -with-prompt.html

我正在使用该代码让我的iPhone应用程序显示一个包含UITextField并匹配CANCEL和OK按钮的alertView 。

I'm using that code to get my iPhone app to display an alertView with an included UITextField and matching CANCEL and OK buttons.

用户可以输入文字,点击CANCEL或OK ...我看到用户输入的文字...使用clickedButtonAtIndex方法中的代码。

The user can enter text, hit CANCEL or OK... and I see the text the user entered... using my code inside the clickedButtonAtIndex method.

这一切都有效,除了一件事:用户可能会在键盘上点击DONE而不是OK。
我正在使用dismissWithClickedButtonIndex来模拟一个OK点击...但是clickedButtonAtIndex永远不会被调用。

It all works except for 1 thing: Instead of OK, the user might hit DONE on the keyboard. I'm using dismissWithClickedButtonIndex to simulate an OK click... but then clickedButtonAtIndex never gets called.

不应该dismissWithClickedButtonIndex也调用clickedButtonAtIndex?

Shouldn't dismissWithClickedButtonIndex also call clickedButtonAtIndex?

如果取消,我试图让clickedButtonAtIndex调用,或者OK,甚至DONE都被击中。

I'm trying to get clickedButtonAtIndex to get called if CANCEL, or OK, or even DONE is hit.

推荐答案

因为这是一个老问题,你现在可能已经想到了,但我对此感到非常沮丧,无法找到谷歌的任何帮助,所以对于今后遇到这种情况的人来说:当你打电话给 dismissWithClickedbuttonIndex 时,方法是被调用的是 alertView:didDismissWithButtonIndex ,而不是 alertView:clickedButtonAtIndex 。它的行为方式完全相同,我无法弄清楚为什么它们是两个独立的方法,似乎是同一个动作,但它确实存在。

Since this is an old question you've probably figured it out by now, but I was incredibly frustrated with this and couldn't find any help from Google, so for anyone who comes across this in the future: when you call dismissWithClickedbuttonIndex, the method that gets called is alertView:didDismissWithButtonIndex, not alertView:clickedButtonAtIndex. It behaves exactly the same way, and I can't figure out why they'd be two separate methods for what seems to be the same action, but there it is.

这篇关于为什么不解雇WithClickedButtonIndex曾经调用过clickedButtonAtIndex?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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