2016-06-21 11 views
1

Die Kreisansicht ist ausgeblendet, wenn die Zelle ausgewählt ist. Wie man es repariert? BringSubviewToFront hilft nicht.Die Kreisansicht ist ausgeblendet, wenn die Zelle ausgewählt ist.

screenshot

override func setSelected(selected: Bool, animated: Bool) { 
    super.setSelected(selected, animated: animated) 
    self.selectedBackgroundView?.bringSubviewToFront(statusView) 
} 

Bitte um Hilfe!

+0

'Zelle auswählen -> Attribut Inspektor -> Auswahl 'auf keine gesetzt und prüfen ... funktioniert es oder nicht ??? –

+0

http://stackoverflow.com/questions/6745919/uitableviewcell-subview-disappears-when-cell-is-selected Dieser Link könnte für Sie nützlich sein – kamwysoc

+0

versuchen Sie, Bildansicht anstelle von uiview –

Antwort

0

gesetzt backgroundColor durch Ihre Sicht des Überschreibung func setHighlighted(highlighted: Bool, animated: Bool) und func setSelected(selected: Bool, animated: Bool) wie folgt aus:

class Cell: UITableViewCell { 
var redView :UIView! 
var yellowView :UIView! 

override init(style: UITableViewCellStyle, reuseIdentifier: String?) { 
    super.init(style: style, reuseIdentifier: reuseIdentifier) 

    redView = UIView() 
    redView.frame = CGRect(x: 0, y: 10, width: 100, height: 20) 
    self.contentView.addSubview(redView) 

    yellowView = UIView() 
    yellowView.frame = CGRect(x: 200, y: 10, width: 100, height: 20) 
    self.contentView.addSubview(yellowView) 

    redView.backgroundColor = UIColor.redColor() 
    yellowView.backgroundColor = UIColor.yellowColor() 
} 

required init?(coder aDecoder: NSCoder) { 
    fatalError("init(coder:) has not been implemented") 
} 

override func setSelected(selected: Bool, animated: Bool) { 
    super.setSelected(selected, animated: animated) 
    redView.backgroundColor = UIColor.redColor() 
    yellowView.backgroundColor = UIColor.yellowColor() 
} 
override func setHighlighted(highlighted: Bool, animated: Bool) { 
    super.setHighlighted(highlighted, animated: animated) 
    redView.backgroundColor = UIColor.redColor() 
    yellowView.backgroundColor = UIColor.yellowColor() 
} 
} 
+0

Ja, das habe ich versucht. Vielen Dank. –

0

Während die Zellen UIView Auswahl, die alle im Hintergrund der Zelle gemalt, so ist die UIView verborgen. Wenn nach Auswahl neu streichen, dann wird alles sein.

override func setSelected(selected: Bool, animated: Bool) { 
    super.setSelected(selected, animated: animated) 

    if selected { 
     switch status { 
     case "8","9": 
      // print("Cancel") 
      statusView.backgroundColor = FlatUIColors.thunderBirdColor() 
     case "10","11","12": 
      // print("Success") 
      statusView.backgroundColor = FlatUIColors.nephritisColor() 
     case "20","21","22","23": 
      // print("Wait") 
      statusView.backgroundColor = FlatUIColors.wetAsphaltColor() 
     case "30","31": 
      // print("Processing") 
      statusView.backgroundColor = FlatUIColors.peterRiverColor() 
     default: 
      break 
     } 
    } 
} 
Verwandte Themen