I am new to swift, I followed this video to do a Collection view and it is working perfectly. But on clicking from one cell to another on clicking is not working.
https://www.youtube.com/watch?v=TQOhsyWUhwg
func collectionView(_ collectionView: UICollectionView,
didSelectItemAt indexPath: IndexPath) {
print("Cell (indexPath.row + 1) clicked")
}
Here it is printing the cell which is selected. I just need to open another view when the cell is clicked. Can anybody help me.
2
Answers
You just need to create object of the another view controller and push it.
like :
Let’s guess the viewController you want to navigate is
SecondViewController
. And Storyboard name isMain
.To navigate a ViewController
Now if you want to navigate viewcontroller from cell tap. Just push that viewcontroller into your navigation stack.