skip to Main Content

I have the parent custom Collectionviewcell and inside I have the child custom Tableview. When I click table view I need to change the background color of collectionviewcell and tableview row background. I am trying achieve using gesture for tableview. but its not working.

3

Answers


  1. Why you don’t use didSelect of tableView?
    Some code should be easy to see how you use gestures.

    Login or Signup to reply.
  2. try with protocols
    first your tableview inform the collection cell

    func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) {
      backgroundColor = .red
      delegate?.didSelectItem(indexPath: indexPath)
    }
    

    then on your collectionView Cell

    func didSelectItem(indexPath: IndexPath) {
      self.backgroundColor = .blue
    }
    
    Login or Signup to reply.
  3. I have created one main array, inside created another array for table content, and manage selection on tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath).

    Please check demo : https://github.com/karan7698007/CollectionViewDemo.git

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search