【发布时间】:2013-04-15 08:12:37
【问题描述】:
我有一个带有 UITextField 的 UIAlertView。我已连接 UIAlertView 委托,并根据 UITextField 中的文本在 alertViewShouldEnableFirstOtherButton: 中返回“是”或“否”。
我需要以编程方式更改 textField 的文本。这按预期工作。
不幸的是,我不知道如何让 UIAlertView 调用 alertViewShouldEnableFirstOtherButton: 委托方法,以便在我更改 textField 的文本后启用或禁用另一个按钮。
我认为 UIAlertView 注册为 UITextField 的目标,所以我尝试从 textField 发送UIControlEventValueChanged。没用。
从堆栈跟踪中我发现委托方法是从私有 UIAlertView 方法_alertSheetTextFieldDidChange: 调用的。
因此,如果我在更改文本后执行[self.currentAlert performSelector:@selector(_alertSheetTextFieldDidChange:) withObject:textField];,则会调用委托方法并且按钮的启用状态会更改。但是,由于这是一个私有方法,应用程序可能会被拒绝。我不想冒险。
有没有一种干净的方法可以让警报视图调用alertViewShouldEnableFirstOtherButton:?
【问题讨论】:
标签: ios cocoa-touch uialertview