Controllers The left red controller is the main one.

From it turns out to transfer data to another red controller.

func collectionView(_ collectionView: UICollectionView, didSelectItemAt indexPath: IndexPath) { let mainStoryboard: UIStoryboard = UIStoryboard(name: "Main", bundle: nil) let firstVC = mainStoryboard.instantiateViewController(withIdentifier: "GroupsViewController") as! GroupsViewController firstVC.name = nameGroupArray[indexPath.row] self.navigationController?.pushViewController(firstVC, animated: true) } 

I do it by analogy with blue controllers, but I cannot switch from the left blue to the right blue controller:

 func collectionView(_ collectionView: UICollectionView, didSelectItemAt indexPath: IndexPath) { let mainStoryboard: UIStoryboard = UIStoryboard(name: "Main", bundle: nil) let secondVC = mainStoryboard.instantiateViewController(withIdentifier: "DetailViewController") as! DetailViewController secondVC.image = imageArray[indexPath.row]! secondVC.name = nameArray[indexPath.row] self.navigationController?.pushViewController(secondVC, animated: true)} 

The data in both left controllers is collectionViewCell (if this is important).

What could be the error?

  • What does "not work" mean? What mistake? - Dmitry Serov
  • Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '- [UILabel setImage:]: unrecognized selector sent to instance - oizo
  • Here is the mistake. On the topic of the question, you are doing everything correctly, correct the error - everything will work. - Dmitry Serov
  • and how to fix it?)) - oizo
  • This is another question, open a new one - Dmitry Serov

0