Swift 中静态 TableView 中特定单元格的披露指示符 [英] Disclosure indicator to specific cell in static TableView in Swift

查看:28
本文介绍了Swift 中静态 TableView 中特定单元格的披露指示符的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我创建了一个静态 TableView,我想添加或删除披露指示器,具体取决于我们是咨询自己的帐户还是访客帐户.

I created a static TableView and I would like to add or remove a disclosure indicator depending if we are consulting our own account or a guest account.

这就是我想要的:

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

let cell = tableView.cellForRow(at: index)
if currentUser {
   cell.accessoryType = .none
   //cell.backgroundColor = UIColor.red
}

我尝试将其放入 viewDidLoad 函数中,但没有成功.我也试过 cellForRowAt indexPath 和同样的结果.

I tried to put it in the viewDidLoad function but it didn't work. I tried cellForRowAt indexPath also and same result.

我怎么能这样做?

推荐答案

您正在使用静态单元格,因此 cellForRow 不会被调用.相反,只需拖动连接您的单元格并进行设置,就像这样

Your are working with static cells so cellForRow will not get called. Instead, simply drag connect your cell and set it up, like this

这篇关于Swift 中静态 TableView 中特定单元格的披露指示符的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆