我试图将较低的细胞保持在它们上方的细胞前面.我在一个单元格中有一个子视图,理想情况下会在下面的单元格后面.我无法找到将代码放在何处执行此操作.我想我应该使用这段代码:
for i in 0 ..< arrayWarningTitles.count{
let cell = tableView.cellForRowAtIndexPath(NSIndexPath(forRow: i, inSection: 0))
self.tableView.bringSubviewToFront(cell!)
}
Run Code Online (Sandbox Code Playgroud)
但我不知道在哪里,因为我已经尝试了一些不同的地方,没有工作过(willDeselectRowAtIndexPath和didSelectRowAtIndexPath方法),我也希望它的初始加载起来为好.任何建议将不胜感激!
更新(添加表格视图代码):
这是我的表格视图代码的大部分,如果它可以帮助任何人,我已删除上面的代码片段,因为它不起作用.
override func tableView(tableView: UITableView, didSelectRowAtIndexPath indexPath: NSIndexPath) {
selection = indexPath.row
tableView.beginUpdates()
tableView.endUpdates()
// self.tableView
}
override func tableView(tableView: UITableView, willDeselectRowAtIndexPath indexPath: NSIndexPath) -> NSIndexPath? {
tableView.beginUpdates()
tableView.endUpdates()
return indexPath;
}
override func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell{
let cell = tableView.dequeueReusableCellWithIdentifier("cell", forIndexPath: indexPath)
cell.selectionStyle = UITableViewCellSelectionStyle.None
cell.backgroundColor = UIColor.clearColor()
// Configure the cell...
let warningTitle = self.view.viewWithTag(1) …Run Code Online (Sandbox Code Playgroud)