- android - RelativeLayout 背景可绘制重叠内容
- android - 如何链接 cpufeatures lib 以获取 native android 库?
- java - OnItemClickListener 不起作用,但 OnLongItemClickListener 在自定义 ListView 中起作用
- java - Android 文件转字符串
我有一个带有 UITextField 的 UIAlertView。我已连接 UIAlertView 委托(delegate),并根据 UITextField 中的文本在 alertViewShouldEnableFirstOtherButton:
中返回 YES 或 NO。
我需要以编程方式更改 textField 的文本。这按预期工作。
不幸的是,我不知道如何让 UIAlertView 调用 alertViewShouldEnableFirstOtherButton:
委托(delegate)方法,以便它在我更改文本字段的文本后启用或禁用其他按钮。
我认为 UIAlertView 注册为 UITextField 的目标,所以我尝试从 textField 发送 UIControlEventValueChanged
。没用。
从堆栈跟踪中我发现委托(delegate)方法是从私有(private) UIAlertView 方法 _alertSheetTextFieldDidChange:
调用的。
因此,如果我在更改文本后执行 [self.currentAlert performSelector:@selector(_alertSheetTextFieldDidChange:) withObject:textField];
,委托(delegate)方法将被调用,按钮的启用状态也会更改。但是,由于这是一个私有(private)方法,该应用程序可能会被拒绝。我不想冒险。
是否有一种干净的方法来使警报 View 调用 alertViewShouldEnableFirstOtherButton:
?
最佳答案
我在发送控制事件方面走在了正确的轨道上。我只是选择了错误的事件。
这会起作用:
[textField sendActionsForControlEvents:UIControlEventEditingChanged];
关于ios - 更改后如何使 UIAlertView 调用 `alertViewShouldEnableFirstOtherButton:`?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16146892/
我想显示带有文本字段的 UIAlertview。如果用户未输入有效的 emai id,则 UIAlertview 的确定按钮将被禁用。 我知道如何显示 UIAlertview 和禁用 UIAlertv
我创建了一个 UIAlertView 子类。它实现了两个 UIAlertViewDelegate 方法:alertView:clickedButtonAtIndex: 在预期时被调用,但是 alert
我有一个带有 UITextField 的 UIAlertView。我已连接 UIAlertView 委托(delegate),并根据 UITextField 中的文本在 alertViewShould
我想显示一条警告消息,我正在使用 iOS SDK 8.1 和 XCode 6.1。我知道 UIAlertView 已被弃用;但是,我的应用程序还必须支持 iOS 7,如果该应用程序在 iOS 7 设备
我目前正在开发一款需要支持 iOS6 和 iOS7 的应用。 我正在创建这样的警报: self.newCategoryAlertView = [[[UIAlertView alloc] initWit
我创建了一个自定义警报 View ,其中包含一个 uitextview subview ,如屏幕截图所示。 alertview with subviewed textview 我想在 TextView
我是一名优秀的程序员,十分优秀!