ViewController와 TableView가 있습니다.
코드를 통해 TableView의 셀을 채우고 다른 코드로 셀의 BackgroundColor를 설정합니다.
참고 - 각 셀의 특정 RGB 값은 다양하지만 코드의 다른 부분에서는
cell.backgroundColor = UIColorFromRGB (0xAA66CC)으로 변경합니다.iOS Swift - 선택한 TableView 셀에서 BackgroundColor 가져 오기
내 Segue에서 다른 뷰를 검색하려면 "Name"요소뿐만 아니라 Cell의 BackgroundColor도 검색하여 다음 ViewController로 보내야합니다.
"Name"이 정상적으로 처리되지만 BackgroundColor 값을 가져 오는 방법을 모르겠습니다.이 값을 전달하기 위해 String으로 변환해야합니다.
내 SEGUE 코드는 다음과 같습니다
override func prepareForSegue(segue: UIStoryboardSeque, sender: AnyObject?)
{
if segue.identifier = "GoToNextVC" {
if let cell = sender as? UITableViewCell {
let destination = segue.destinationViewController as! NextVC
let indx = tableView.IndexPathForCell(cell).row
destination.SelectedValue = self.peripherals[indx].name // This works fine.
destination.SelectedColor = **< I don't know what to do here >**
}
}
}
그 코드는 SelectedObject 이름을 얻기 위해 작동하지만 난 다음 SEGUE를 통해 전달할 수 있도록 셀의 backgroundColor로 활용하는 방법을 모르겠습니다.
귀하의 협조에 큰 도움이 될 것입니다. 당신이 셀이있는 경우
cell.backgroundColor
다음 색상을 얻을 수 있습니다 :
나는 그것을 시도했지만 분명히 잘못된 것이있다. 'cell.backgroundColor'? –
try cell.contentView.backgroundColor –