问题标签 [uialertaction]
For questions regarding programming in ECMAScript (JavaScript/JS) and its various dialects/implementations (excluding ActionScript). Note JavaScript is NOT the same as Java! Please include all relevant tags on your question; e.g., [node.js], [jquery], [json], [reactjs], [angular], [ember.js], [vue.js], [typescript], [svelte], etc.
swift - 你应该如何处理 UIAlertAction 的闭包参数
我一直在尝试创建一个UIAlertAtion
也有处理程序的。我阅读了这个问题的答案,并且知道该怎么做。
我的问题只是关于它的关闭部分。
1)我知道我会写:{alert in println("Foo")}
或者{_ in println("Foo")}
但我不会写{println("Foo")}
。在这里的评论中进行了解释,因为您需要处理参数 action。
这是否意味着由于处理程序的类型是(UIAlertAction) -> Void)?
我必须始终捕获传递的警报动作?
2)
我也读了这个,答案基本上是说你可以传入一个函数作为你的参数,但函数应该采用 type 的东西UIAlertAction -> Void
,我写了:
然后这样写了我的警报动作:
困惑为什么我会收到那个错误
3) 在评论中还说:但除此之外,您不必快速编写 UIAlertActionStyle.Default 。.Default 也可以
我尝试不使用样式编写,因此默认为.Default
但后来我收到以下错误:
'(title: String, (_) -> ())' (aka '(title: String, _ -> ())') 不能转换为 '(title: String?, style: UIAlertActionStyle, handler: (( UIAlertAction) -> Void)?)' (aka '(title: Optional, style: UIAlertActionStyle, handler: Optional ()>)'),元组有不同数量的元素
4)
同时阅读这个答案。我不明白为什么我们需要传递alert
它是没有意义的。并不是不知道 alert 的类型是什么……我们不是已经定义了它的类型了吗?!!谁能解释一下传递动作本身通常在哪里有用,我的意思是我们能用它做什么?
我知道这是写成 4 个问题,但我认为这实际上只是一个基础问题。我已经广泛阅读,在我正在操场上工作和玩耍的项目中使用了闭包/完成处理程序,但我仍然感到困惑。
annotations - 如何添加通过右标注附件视图操作按钮拨打电话的功能?
我想要做的是,当有人通过下面的 UIAlertAction 序列按下“呼叫位置”按钮时,我希望它加载电话并拨打我之前在代码中估算的电话号码(在 ViewDidLoad 中)。这是我的 annotationView - calloutAccessory 代码,我必须这样做:
我将如何编码?
注意:我是编码新手,因此不胜感激。
更新:我自己想通了。在第一行 ac.addAction 中,我将其更改为:
ios - 如何在目标 c 中更改 uialertcontroller 中的 uialertaction 框架
我alertView
在整个应用程序中添加。我想更改确定或取消按钮的大小, alertView
以便我可以设置动作的小图像。
任何人都请帮助我。
swift - 使用 Swift 3 在警报消息框标题中添加图像
我想在警报消息标题而不是标题文本中添加共享图像。
如何使用 swift 3 实现这一点?
ios - 我的警报控制器操作究竟如何将文本附加到标签?
基本上,我设置了一个警报控制器,以便当我单击视图控制器中的按钮时,会弹出一个警报控制器,我可以在文本字段中输入单词,然后单击“确定”按钮。
参考图像
(来源:ashfurrow.com)
并将该文本插入到视图控制器的标签中。我扩展了此功能,以便我可以在警报控制器中选择预设关键字(如“好”、“可能”和“几乎”)以加快输入过程,因为这些词在我的应用程序。如下图所示
.
我想知道您是否也可以将我选择的那些关键词添加到标签中的任何内容中?每次我尝试单击预设关键字添加到标签时,它都会删除标签中已有的内容。
具体来说,无论我的标签中已有什么文本,我可以选择一个预设关键字附加到标签中的内容吗?
这是我到目前为止的第二张图片:
请帮忙!您将如何在 swift 3 中执行此操作?
ios - UIAlertAction with different color button text
I am trying to create an UIAlertAction that has black color text for the first button and blue for the second. If I change the tint then all go black but i can't change the first button to black without it. Below is my code:
#xA;swift3 - UIAlertView inside UIAlertAction in Swift 3.0 ?
Is it possible to add UIAlert view inside UIAlertAction ?
Because when I tried to add UIAlert view inside UIAlertAction, it says
"Warning: Attempt to present on whose view is not in the window hierarchy!"
Here's my code.