I have CollectionViewController, when I am trying to click on cell and navigate to respective ViewControllers its not working.how can I solve this issue.
func collectionView(_ collectionView: UICollectionView, didSelectItemAt indexPath: IndexPath) {
let cell:AddOptionCollectionViewCell = collectionView.cellForItem(at: indexPath) as! AddOptionCollectionViewCell
if (cell.name.text == "CONTRAST"){
let storyBoard: UIStoryboard = UIStoryboard(name: "Main", bundle: nil)
let newViewController = storyBoard.instantiateViewController(withIdentifier: "ContrastViewController") as! ContrastViewController
self.navigationController?.pushViewController(newViewController, animated: true)
}
selfin a navigation controller?ifstatement is always going to return true. I would suggest thoroughly reading theUICollectionViewdocumentation before proceeding.show(newViewController, sender: self)to directly accessing the navigation controller