如何更改现有 UIAlertAction 的标题?

Chr*_*gel 2 uikit ios swift

我在操作表中有一个喜欢按钮:

likeAction = UIAlertAction(title: "Like this post", style: UIAlertActionStyle.Default, handler: { (action) -> Void in
        println("like pressed")
})
Run Code Online (Sandbox Code Playgroud)

一旦按下,我想将标题更新为“与此帖子不同”

标题是只读的,并且 UIAlertActions 上没有 SetTitle() 函数。

非常感谢您的想法。

Ash*_*hik 5

这对我有用。

self.alertAction.setValue("New Title", forKeyPath: "title")
Run Code Online (Sandbox Code Playgroud)

希望这可以帮助。