【问题标题】:Dropdown in swift with button and UITableView使用按钮和 UITableView 快速下拉
【发布时间】:2019-06-04 06:42:19
【问题描述】:

我想使用 swift 在我的 ios 应用程序中使用下拉菜单。到目前为止,我通过观看这个下拉视频已经实现了一切 I have created drop down using this link

但是当我打印按钮标题时

func tableView(_ tableView: UITableView, didSelectRowAt indexPath:IndexPath{ let buttonTitle = btntitle.setTitle("\(fruits[indexpath.row])", for:.normal) print(buttonTitle)}

它在我的输出中显示--> ()

谁能帮我解决这个问题,好吗?

【问题讨论】:

  • let buttonTitle = btntitle.setTitle("\(fruits[indexpath.row])", for:.normal) 更改为let buttonTitle = fruits[indexPath.row]

标签: swift uitableview dropdown


【解决方案1】:

您正在将函数 setTitle(返回 void)分配给您的 buttonTitle 变量。当您打印该变量时,您会看到 ()

您可能会在该行看到警告。

修改如下:

let buttonTitle = fruits[indexpath.row]
btntitle.setTitle(buttonTitle, for: .normal)

【讨论】:

    猜你喜欢
    • 2017-12-23
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2015-10-21
    • 1970-01-01
    • 2017-02-06
    • 2016-09-02
    相关资源
    最近更新 更多