告诉我如何从imagePickerController函数更改单元格的backGroundColor
:
func imagePickerController(_ picker: UIImagePickerController, didFinishPickingMediaWithInfo info: [UIImagePickerController.InfoKey : Any]) {
self.dismiss(animated: true, completion: nil)
//let imageUser = info[UIImagePickerController.InfoKey.editedImage] as! UIImage
let indexPath = IndexPath(item: 0, section: 0)
let cell = collectionView.dequeueReusableCell(withReuseIdentifier: "cellRegisterMarket", for: indexPath) as! cellRegisterMarket
cell.backgroundColor = .red
}
答案 0 :(得分:2)
替换此
$func = 'set'.$field;
使用
let cell = collectionView.dequeueReusableCell(withReuseIdentifier: "cellRegisterMarket", for: indexPath) as! cellRegisterMarket
这不是一个好方法,更新模型并重新加载集合
答案 1 :(得分:2)
您应该尝试以下方法:
let indexPath = IndexPath(item: 0, section: 0)
let cell = collectionView.cellForItemAtIndexPath(indexPath) as! cellRegisterMarket
cell.backgroundColor = .red