Ios Swift中静态表视图中特定单元格的泄露指示器

Ios Swift中静态表视图中特定单元格的泄露指示器,ios,swift,uitableview,swift3,indexpath,Ios,Swift,Uitableview,Swift3,Indexpath,我创建了一个静态的TableView,我想添加或删除一个披露指标,这取决于我们是咨询自己的账户还是客户账户 这就是我想要的: let index = IndexPath(row: 4, section: 0) let cell = tableView.cellForRow(at: index) if currentUser { cell.accessoryType = .none //cell.backgroundColor = UIColor.red } 我试着把它放在view

我创建了一个静态的TableView,我想添加或删除一个披露指标,这取决于我们是咨询自己的账户还是客户账户

这就是我想要的:

let index = IndexPath(row: 4, section: 0)

let cell = tableView.cellForRow(at: index)
if currentUser {
   cell.accessoryType = .none
   //cell.backgroundColor = UIColor.red
}
我试着把它放在viewDidLoad函数中,但它不起作用。我也尝试了cellForRowAt,结果是一样的


我该怎么做呢?

只要检查一下是否要在cellForRowAt Indexath方法中显示披露指标

if (wantsToShow){ // Your condition goes here
   cell.accessoryType = UITableViewCellAccessoryType.DisclosureIndicator
}
else{
   cell.accessoryType = .none
}

就这样。

请在cellForRowTableView代码中使用以下代码

它会对你有用的

 func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell{ 
    if currentUser {
     // Own Account
       cell.accessoryType = .none
       //cell.backgroundColor = UIColor.red
    }else{
     //Guest Account
     cell.accessoryType =.checkmark
    }
}

您正在使用静态单元格,因此不会调用
cellForRow
。相反,只需拖动连接单元格并进行设置,如下所示


要在特定的静态单元格上添加附件,我使用了tableView、cellForRowAt,但无法访问UITableViewCell的引用

然后我找到super.tableView(tableView,cellForRowAt:indexPath)

这是我的代码: 假设您知道所需的特定索引XPath:

    var indexPathSort = IndexPath(item: 0, section: 0)
    var indexPathPrice = IndexPath(item: 0, section: 1)


override func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
            let cell = super.tableView(tableView, cellForRowAt: indexPath)
            if indexPath == indexPathSort || indexPath == indexPathPrice {

                cell.accessoryType = .checkmark
            }
            return cell
        }

还有别的吗?那只是移除了附件。。。在哪里设置?如果单元格是静态的,请使用
IBOutlet
s直接访问单元格。问题是它是一个静态表视图,我只希望在单元格[0,4]上执行此操作。。。