我的表格 View 将披露指示器作为附件。此 tableview 单元格的 didSelectItem()
调用在后台执行 api 调用。因此 View 需要等到响应才能显示下一页。我必须为披露指示器的位置提供一个事件指示器。怎么可能像在 ios 设置页面中一样
func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
// Returns the cell value for each index
let cell = tableView.dequeueReusableCell(withIdentifier: TenantCell.identifier, for: indexPath) as! TenantCell
cell.populate(with: tenantList[indexPath.row])
return cell
}
func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) {
Api.domain = tenantList[indexPath.row].url!
sharedAFManager.getJsonData(api: Api.theme, completionHandler: { (response, statusCode) in
if let theme = response {
Api.logo = theme["logo"].stringValue
Constants.passwordRegx = theme["passwordRegex"].stringValue
self.performSegue(withIdentifier: Segue.login, sender: indexPath.row)
}
})
}
/// UITableview cell populating tenant informations
class TenantCell: UITableViewCell {
@IBOutlet weak var tenantImage: UIImageView!
@IBOutlet weak var tenantNameLabel: UILabel!
@IBOutlet weak var tenantUrlLabel: UILabel!
func populate(with tenant: Tenant) {
tenantNameLabel?.text = tenant.name
tenantUrlLabel?.text = tenant.url
tenantImage.image = UIImage(named: "breifcase")
}
}
最佳答案
请写在cellForRowAt
方法中:
cell.accessoryType = .disclosureIndicator
然后在didSelectRowAt
方法中请写
guard let cell : TenantCell = (tableView.cellForRow(at: indexPath) as! TenantCell) else {
return
}
cell.accessoryView = activityIndi
activityIndi. startAnimating()
得到响应后
activityIndi. stopAnimating()
也许对你有帮助。谢谢
关于swift - 在表格 View 行的右侧显示事件指示器,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/53993340/