gpt4 book ai didi

uitableview - Swift UITableViewCell 对齐

转载 作者:搜寻专家 更新时间:2023-10-31 08:23:38 24 4
gpt4 key购买 nike

我正在尝试显示如下页面

页面标题(左对齐)

区域名称(居中对齐)

该地区的人(详细标签中带有电子邮件的副标题)

但是如果我选择副标题作为单元格样式,所有内容都将左对齐并且我无法在代码中更改它们。然后,如果我选择自定义作为样式,则 detailtextlabel 将不会显示。

if(poDetailList.LastName == "POName"){
cell.backgroundColor = SharedClass().coopGroupHeaderColor
let selectedColor = UIView()
selectedColor.backgroundColor = SharedClass().coopGroupHeaderColor
cell.selectedBackgroundView = selectedColor
cell.textLabel?.textColor = UIColor.blackColor()
cell.textLabel?.font = UIFont.boldSystemFontOfSize(15.0)
cell.textLabel?.textAlignment = .Center
cell.accessoryType = .None
var t_header = ""
if(POShort != "OTHER" && POShort != "all" && POShort != "invalid"){
t_header = POName
}
else{
t_header = POName
}
cell.textLabel?.text = t_header
cell.detailTextLabel?.text = ""
cell.userInteractionEnabled = false;
} else{
cell.backgroundColor = indexPath.row % 2 == 0 ? UIColor.clearColor() : SharedClass().cellBackGroundColor
let selectedColor = UIView()
selectedColor.backgroundColor = SharedClass().selectedCellColor
cell.selectedBackgroundView = selectedColor
cell.textLabel?.font = UIFont.boldSystemFontOfSize(15.0)
cell.textLabel?.textAlignment = .Left
cell.accessoryType = UITableViewCellAccessoryType.DisclosureIndicator
var t_header = poDetailList.FirstName
cell.textLabel?.text = "Name:" + poDetailList.FirstName + " " + poDetailList.LastName
cell.detailTextLabel?.text = "Not Responded In Days:" + poDetailList.DaysNotResponded
cell.userInteractionEnabled = true;
}

谁能帮我解决这个问题?

非常感谢

最佳答案

为两个标签设置对齐方式

cell.textLabel?.textAlignment = .Left
cell.detailTextLabel?.textAlignment = .Right

我希望它有用!!!

关于uitableview - Swift UITableViewCell 对齐,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30596940/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com