草庐IT

uialertaction

全部标签

ios - 如何根据 UITextField 禁用 UIAlertAction?

我有一个action,它会在点击按钮时创建一个alert。这个alert包含两个textfields和两个actions(add和dismiss).如果textfields为空,我有什么简单的方法可以禁用add按钮(稍后我会检查第二个是否真的是URL,但让我们让事情专注于此处的action)?这是我的代码和我到目前为止尝试过的:@IBActionfuncaddSourceTapped(_sender:Any){letalert=UIAlertController(title:"AddaNewsSource",message:nil,preferredStyle:.alert)alert

ios - 如何使用 OCMock 测试 UIAlertAction 处理程序的内容

我有一个应用程序,我在其中推送一个带有多个自定义UIAlertAction的UIAlertController。每个UIAlertAction在actionWithTitle:style:handler:的处理程序block中执行独特的任务。我有几个方法需要验证是否在这些block中执行。如何执行handlerblock,以便验证这些方法是否已执行? 最佳答案 经过一番尝试,我终于弄明白了。事实证明,handlerblock可以转换为函数指针,并且可以执行函数指针。像这样UIAlertAction*action=myAlertCon

ios - UIAlertController 显示 UIAlertActions 的空白标题

最近,我终于重构了一个遗留项目,并将所有UIAlertViews和UIActionSheets转换为UIAlertControllers。但我已经开始收到来自客户的问题,他们说有时UIAlertController操作标题是空白的。像这样:我无法在我的设备上重现此错误,您对可能的原因有任何想法吗?更新:我相信,该问题已包含在该代码中,也许主窗口的tintColor不是默认的,UIAlertController继承了它?@implementationUIAlertController(WMC)-(void)show:(BOOL)animated{self.alertWindow=[[UI

ios - UIAlertAction 的处理程序有点太晚了——我怎样才能让它立即生效?

我正在尝试(...)为添加到UIAlertController的按钮添加声音效果。我在处理程序中发出声音效果,但这实际上有点太晚了。声音响起就像晚了0.5秒。我希望声音在警报即将解除时立即触发,而不是在解除后触发。使用UIAlertView可以使用alertWillDismiss...而不是alertDidDismiss来处理。我错过了什么吗? 最佳答案 不,你没有错过任何东西。UIAlertController不提供您正在寻找的功能。考虑提供您自己的呈现ViewController,您可以通过它进行精细控制。

ios - 如何更改 iOS 中的 UIAlertAction 按钮颜色?

我有一个UIAlertController和一堆UIAlertAcion按钮。现在我需要用其他颜色而不是相同的颜色来显示一个按钮。对于前者Button1Button2Button3Button1andbutton3shouldbeinblueandbutton2shouldbeinred.这可能吗?怎么办?只是抛出你的想法...我的代码:UIAlertController*actionSheet=[UIAlertControlleralertControllerWithTitle:@"FoodMenu"message:@"SelecttheMenuItem"preferredStyle

ios - 如何从 Swift 中的 UIAlertController 中删除 UIAlertAction?

我知道您可以在UIAlertController中禁用UIAlertAction按钮,但是是否可以在添加按钮后将其完全删除? 最佳答案 一旦添加,就不可能从UIAlertController中删除操作。actions属性可以返回添加的Action数组,但只是一个get,不能设置。Action是通过addAction(_:)方法添加的,但是没有相应的removeAction(_:)方法。最终,一旦添加了警报Controller就从中删除操作并没有多大意义。您通常应该在实例化后重用警报Controller对象,因此解决方案是首先只添加适

ios - 在 iOS UIAlertController 中,我们可以左对齐 UIAlertAction 的文本吗

我需要实现一个UIAlertController,例如这个UIAlertController,左对齐UIAlertAction在互联网和stackoverflow中进行大量搜索后,我能够实现UIAlertController的左对齐标题但是如何左对齐UIAlertAction的文本?任何帮助/线索都会非常有帮助。 最佳答案 是的,你可以,用下面的[(youruialertactionobject)setValue:@0forKey:@"titleTextAlignment"] 关于ios

swift - 从 UIAlertAction 获取 UIAlertController?

我想调用函数而不是使用带有UIAlertAction的闭包。是否可以获得对拥有UIAlertAction的UIAlertController的引用?alert=UIAlertController(title:"City",message:"Enteracityname",preferredStyle:UIAlertControllerStyle.Alert)UIAlertActionStyle.Default,handler:okAlert)//...funcokAlert(action:UIAlertAction){//Gettoalertherefromaction?}

ios - 使用动态项目获取 UIAlertAction 的选择索引

我正在构建一个动态的操作列表。当按下一个Action时,我想跳转到表格View中的一个部分。为此,我想知道操作的选定索引并将其替换为代码部分:“inSection:0”。有什么办法吗?这是我的代码:letoptionMenu=UIAlertController(title:nil,message:"Jumpto",preferredStyle:.ActionSheet)foriteminitems{letaction=UIAlertAction(title:item,style:.Default,handler:{(alert:UIAlertAction!)->Voidinletind

swift - 无法将类型 'UIAlertAction' 的值转换为预期的参数类型 'UIViewController'?

我正在尝试在新的Xcode更新8.3.2中做简单的警报我在显示警报对话框时遇到问题:@IBActionfunctestButonAlert(){letalertAction=UIAlertAction(title:"HiTEst",style:UIAlertActionStyle.destructive,handler:{(UIAlertActionStyle)->Voidinprint("")})self.present(alertAction,animated:false,completion:nil)}错误:Cannotconvertvalueoftype'UIAlertActi