Mat*_*uch 7 cocoa-touch uialertview ios
我有一个带UITextField的UIAlertView.我连接了UIAlertView委托,并alertViewShouldEnableFirstOtherButton:根据UITextField中的文本返回YES或NO .
我需要以编程方式更改textField的文本.这按预期工作.
不幸的是我不知道如何让UIAlertView调用alertViewShouldEnableFirstOtherButton:委托方法,因此在我更改textField的文本后启用或禁用其他按钮.
我认为UIAlertView注册为UITextField的目标,所以我尝试UIControlEventValueChanged从textField 发送一个.没工作.
从堆栈跟踪中我发现从私有UIAlertView方法调用委托方法_alertSheetTextFieldDidChange:.
因此,如果我[self.currentAlert performSelector:@selector(_alertSheetTextFieldDidChange:) withObject:textField];在更改文本后执行操作,则会调用委托方法并更改按钮的启用状态.但是,由于这是一种私有方法,应用程序可能会被拒绝.我不想冒这个风险.
是否有一种干净的方式来进行警报视图调用alertViewShouldEnableFirstOtherButton:?
发送控制事件我在正确的轨道上.我只是选择了错误的事件.
这将有效:
[textField sendActionsForControlEvents:UIControlEventEditingChanged];
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
1051 次 |
| 最近记录: |