第一行和第二行之间缺少swift表格视图分隔线
我创建了一个表,第一个和第二个单元格之间的分隔线似乎丢失了,其余的都在那里。如果我滚动到顶部并向后滚动,将显示以下行: 下面是tableview行函数。我从mysql数据库读取数据并显示行第一行和第二行之间缺少swift表格视图分隔线,swift,tableview,cell,Swift,Tableview,Cell,我创建了一个表,第一个和第二个单元格之间的分隔线似乎丢失了,其余的都在那里。如果我滚动到顶部并向后滚动,将显示以下行: 下面是tableview行函数。我从mysql数据库读取数据并显示行 func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int { return dbarray_id.count } func tableView(_ tableView: UITabl
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
}
func tableView(tableView:UITableView,numberofrowsinssection:Int)->Int
{
返回dbarray\u id.count
}
func tableView(tableView:UITableView,cellForRowAt indexath:indexPath)->UITableViewCell
{
//对于(变量i=0;i //对于0..中的i,我相信设置:
cell.selectionStyle = .none
然后以编程方式选择单元格,如viewDidLoad方法中的单元格,将导致此错误。
我也遇到了同样的问题,并使用附件复选标记和禁用选择功能解决了它。在我删除默认选择第一个单元格的代码后,错误消失了。是模拟器的屏幕截图还是真实设备?在真实设备上检查,在模拟器上看起来像是,但在设备上它会工作。我检查了模拟器和iPad,并且相同,第一行和第二行之间没有一行。你能提供一些示例代码吗?也许你的单元格重叠了分隔符或类似的东西。试着在100%缩放下运行模拟器。