【问题标题】:How do i change the title of an existing UIAlertAction?如何更改现有 UIAlertAction 的标题?
【发布时间】:2015-07-01 17:36:59
【问题描述】:

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

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

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

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

非常感谢您的想法。

【问题讨论】:

  • 设置一个布尔变量来指示帖子是否被“喜欢”,然后有条件地设置警报标题。
  • 对...我想错了。谢谢你。问这个问题很有帮助。 :-)

标签: ios swift uikit


【解决方案1】:

这对我有用。

self.alertAction.setValue("New Title", forKeyPath: "title")

希望这会有所帮助。

【讨论】:

    【解决方案2】:

    Lyndsey Scott in a comment 在原帖中回答了这个问题。

    设置一个布尔变量来指示帖子是否被“喜欢”,然后有条件地设置警报标题。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2019-02-23
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2021-09-26
      • 2017-12-08
      相关资源
      最近更新 更多