【问题标题】:How to check if a UIButtons title is equal to a specific string?如何检查 UIButtons 标题是否等于特定字符串?
【发布时间】:2020-09-19 06:35:59
【问题描述】:

我正在尝试有一个可以单击的按钮,如果标题是那个字符串,它将执行 x,否则不会。

if button.setTitle("Message", for: .normal) == true {

} else {

}

【问题讨论】:

    标签: ios swift xcode boolean


    【解决方案1】:

    您可以使用currentTitle property 来检查您想要的值。

    setTitle 方法应该用于设置/更新标题值,而不是获取它。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2016-12-21
      • 2014-07-29
      • 1970-01-01
      • 2021-12-11
      • 1970-01-01
      • 2011-02-05
      • 1970-01-01
      • 2014-01-08
      相关资源
      最近更新 更多