单击警报操作后禁用表格视图单元格选择

问题描述

问题的主要目标是在单击 Off_shelve 操作后,所选单元格将被禁用并将 alpha 变为不同的颜色,让用户知道此单元格不可用。此外,如果用户单击 On_Shelve 操作,将再次访问所选单元格。

这可行吗?

Simulator Image

解决方法

设置 UITableViewDataSourceUITableViewDelegate

override func viewDidLoad() {
    super.viewDidLoad()

    self.tableView.delegate = self
    self.tableView.dataSource = self
}

获取cell中的didSelectRowAtIndexPath

func tableView(tableView: UITableView,didSelectRowAtIndexPath indexPath: NSIndexPath) {
   if let cell = tableView.cellForRow(at: indexPath) as? MyTableViewCell {
         // DO whatever you want here with the selected sell.
    }
}

在您的情况下,对 Alert 中的按钮单击操作进行更改。简单。