重新加载滚动视图的内容

Reloading contents of scroll view

有没有办法在滚动视图中重新加载数据?我在第二个点击时在滚动视图上有 5 个按钮我想将第一个按钮重新加载到正常状态是否可能?实际上我有 table 视图,我有 2 行。 Table 视图单元格有一个滚动视图,在该滚动视图上我添加了用于水平滚动的按钮我知道 table 重新加载但是我的按钮在滚动视图上所以我被卡住了。有人可以帮忙吗?

直接打电话

tableView.reloadRows(at: [IndexPath], with: UITableViewRowAnimation)

并且在 TableViewDataSource 方法中:

func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell

再次设置带有按钮的 ScrollView

要更新多个按钮,您可以这样做...

首先创建一个按钮数组...

let buttons = [button1, button2, button3, button4, ...]

现在在你的目标行动中...

func buttonTapped(button: UIButton) {
    // filter buttons to get the ones not tapped
    buttons.filter { [=11=] != button }
    // set them all to be deselected
           .forEach { [=11=].isSelected = false }
}

或者类似这样的东西。

这实际上取决于您如何创建它们等,但这是一种非常简单的方法,无需更多了解您的具体情况。