gpt4 book ai didi

第一行和第二行之间缺少 swift tableview 分隔线

转载 作者:行者123 更新时间:2023-11-28 06:19:28 26 4
gpt4 key购买 nike

我创建了一个表格,第一个和第二个单元格之间的分隔线似乎丢失了,其余的都在那里。如果我滚动到顶部并返回,则会出现该行: enter image description here

下面是 TableView 行函数。我从 mysql 数据库读取并显示行。

func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int
{
return dbarray_id.count
}

func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell
{
//for(var i = 0; i < dbarray_id.count; i += 1)
//for i in 0..<dbarray_code.count
//{
// //newVars.put_timelog("cellForRowAtIndexPath_uiswitch :\(uiswitch_onoff[i]) \(uiswitch_enabled[i])")
//}

let cell = tableView.dequeueReusableCell(withIdentifier: "pushgroups_tvc") as! pushgroups_tvc

cell.backgroundColor = UIColor.clear

cell.txtsubject.text = dbarray_title[(indexPath as NSIndexPath).row]
cell.txtbody.text = dbarray_description[(indexPath as NSIndexPath).row]

cell.txtsubject.numberOfLines=0
cell.txtsubject.lineBreakMode = NSLineBreakMode.byWordWrapping

cell.txtbody.numberOfLines=0
cell.txtbody.lineBreakMode = NSLineBreakMode.byWordWrapping

cell.txtsubject.textColor = UIColor.blue
cell.txtsubject.font = newVars.font_subject
cell.txtbody.font = newVars.font_body

cell.addgroup.tag = (indexPath as NSIndexPath).row
//update switch to selected value
//cell.addgroup.on = false
cell.addgroup.isOn = uiswitch_onoff[(indexPath as NSIndexPath).row]
if uiswitch_enabled[(indexPath as NSIndexPath).row] == true
{
cell.addgroup.isEnabled = true
cell.addgroup.backgroundColor = UIColor.clear
}
else
{
cell.addgroup.isEnabled = false
cell.addgroup.backgroundColor = UIColor.clear
}

cell.txtaccesscode.text = ""
cell.txtaccesscode.isEnabled = true

cell.txtaccesscode.tag = (indexPath as NSIndexPath).row
cell.txtaccesscode.tintColor = UIColor.blue
cell.txtaccesscode.autocapitalizationType = .allCharacters


//GGGGGG
cell.txtaccesscode.addTarget(self, action: #selector(textFieldTyping_access), for: .editingChanged)

if dbarray_public[(indexPath as NSIndexPath).row] == "Y"
{
//cell.backgroundColor = UIColor.blueColor().colorWithAlphaComponent(0.2)
cell.txtaccesscode.text = ""
cell.txtaccesscode.isEnabled = false
cell.addgroup.isEnabled = true
cell.txtaccesscode.isHidden = true
}
if dbarray_public[(indexPath as NSIndexPath).row] == "R"
{
cell.txtaccesscode.isHidden = false
//cell.backgroundColor = UIColor.redColor().colorWithAlphaComponent(0.2)
}
if dbarray_public[(indexPath as NSIndexPath).row] == "H"
{
//cell.backgroundColor = UIColor.greenColor().colorWithAlphaComponent(0.2)
}

cell.selectionStyle = .none
cell.layoutMargins = UIEdgeInsets.zero
cell.separatorInset = UIEdgeInsets.zero
cell.layoutMargins = UIEdgeInsets.zero

cell.backgroundColor = newVars.hexStringToUIColor(hex: newVars.tableview1_background_color).withAlphaComponent(CGFloat(newVars.tableview1_background_color_alpha))

return cell
}


func tableView(_ tableView: UITableView, willDisplay cell: UITableViewCell, forRowAt indexPath: IndexPath)
{
newVars.put_timelog(timedata: "GORDON pushgroups_vc_textFieldDidBeginEditing(textField ")

//tableView.separatorStyle = UITableViewCellSeparatorStyle.singleLineEtched
tableView.separatorStyle = UITableViewCellSeparatorStyle.singleLine
tableView.separatorColor = UIColor.black
//tableView.backgroundColor = UIColor.red //overrides cell color
tableView.showsHorizontalScrollIndicator = false
tableView.showsVerticalScrollIndicator = false
}

最佳答案

我相信设置:

cell.selectionStyle = .none

然后以编程方式选择一个单元格,就像在 viewDidLoad 方法中一样会导致此错误。我有同样的问题并使用附件复选标记和禁用选择解决了它。在我删除默认选择第一个单元格的代码后,错误消失了。

关于第一行和第二行之间缺少 swift tableview 分隔线,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/44099683/

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