【问题标题】:How to change the text of a button to a variable? [duplicate]如何将按钮的文本更改为变量? [复制]
【发布时间】:2017-09-07 03:26:13
【问题描述】:
let cell = tableView.dequeueReusableCell(withIdentifier: "cell", for: <#T##IndexPath#>) as! TableViewCell
    cell.myButton. =  recipies[indexPath.row]
}

我不知道在cell.mybutton.之后添加什么。

这段代码的顶部在 Xcode 中也被标记为不正确

【问题讨论】:

    标签: ios swift uibutton


    【解决方案1】:

    漂亮又简单

    cell.myButton.setTitle(recipies[indexPath.row], for: UIControlState.normal)
    

    【讨论】:

    • 请不要回答重复的问题。相反,将它们标记为重复。
    • 它说“'UIView' 类型的值没有成员 'setTitle' -- 大声笑,请帮助我,我是 Xcode 新手
    • 好的 - 你有一个不同的问题,看起来 myButton not 实际上定义为 UIButton。您能否包含定义“myButton”的代码 - 无论是在哪里创建 myButton = UIButton ... 还是您附加到的插座?
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2016-08-01
    • 2022-07-07
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多