Sto cercando di mantenere le celle inferiori davanti alle celle sopra di esse. Ho una sottoview in una cella che idealmente andrebbe dietro la cella sottostante. Sto avendo difficoltà a trovare dove mettere il codice per farlo. Penso che dovrei usare questo frammento di codice:Mantieni UITableViewCell davanti ad altre celle
for i in 0 ..< arrayWarningTitles.count{
let cell = tableView.cellForRowAtIndexPath(NSIndexPath(forRow: i, inSection: 0))
self.tableView.bringSubviewToFront(cell!)
}
ma non sono sicuro di dove, come ho cercato un paio di posti diversi e nessuno ho lavorato (willDeselectRowAtIndexPath e didSelectRowAtIndexPath), e vorrei anche simile anche sul carico iniziale. Ogni suggerimento sarà molto apprezzato!
UPDATE (Aggiunto Table View Codice):
Ecco la maggior parte della mia tabella dei codici di vista, se aiuta nessuno, ho rimosso il frammento di cui sopra in quanto non sta funzionando.
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) as? UILabel
let expirationTime = self.view.viewWithTag(2) as? UILabel
let textView = self.view.viewWithTag(5) as? UITextView
let grayBackground = self.view.viewWithTag(6)
let redBackground = self.view.viewWithTag(7)
warningTitle?.text = arrayWarningTitles[indexPath.row]
redBackground!.layer.masksToBounds = true;
redBackground!.layer.cornerRadius = 20;
grayBackground!.layer.masksToBounds = true;
grayBackground!.layer.cornerRadius = 20;
redBackground?.clipsToBounds = false;
cell.clipsToBounds = false;
cell.contentView.clipsToBounds = false;
cell.contentView.superview?.clipsToBounds = false;
self.tableView.bringSubviewToFront(cell)
return cell
}
override func tableView(tableView: UITableView, heightForRowAtIndexPath indexPath: NSIndexPath) -> CGFloat
{
if (indexPath.row == selection) { //change 0 to whatever cell index you want taller
return UIScreen.mainScreen().bounds.height - 140 - 64;
}
return 58;//Choose your custom row height
}
Perché le celle si sovrappongono? Puoi dire di più su ciò che hai e ciò che stai cercando di realizzare? –
Voglio creare una vista verticale del tipo di carta, con le informazioni visualizzate appena sopra la cella sottostante. – JordanWx
Non posso dire di sicuro senza vedere la tua piena implementazione, ma il mio istinto è che lo inseriresti in 'tableView (_: willDisplay: forRowAt:)'. Ma questo è un trucco: 'UITableView' non supporta realmente i layout come quello. Una soluzione più robusta userebbe 'UICollectionView' –