I have a UIViewController where i need to pass information.For that i have made another UIViewController where i have a CollectionView.
So when a user clicks on an element from the CollectionView it should close the view and go back to the main UIViewController.
So i have managed to get it working with a button in the Navigaiton bar.
But when i place the same code
"dismissViewControllerAnimated(true, completion: nil)"
in the didSelectItemAtIndexPath its not working.
I have tried to place a button in the cell but still same result everything works except that.
func collectionView(collectionView: UICollectionView, numberOfItemsInSection section: Int) -> Int {
return self.exercisesNames.count
}
func collectionView(collectionView: UICollectionView, cellForItemAtIndexPath indexPath: NSIndexPath) -> UICollectionViewCell {
let cell = collectionView.dequeueReusableCellWithReuseIdentifier("cellexercises_insert", forIndexPath: indexPath) as! Insert_ExerciseCollectionViewCell
cell.insert_exerciseImage?.image = self.exercisesImages[indexPath.row]
cell.insert_exerciseLabel?.text = self.exercisesNames[indexPath.row]
cell.insert_exercisesHardnessImg?.image = self.exercisesHardnessImg[indexPath.row]
return cell
}
func collectionView(collectionView: UICollectionView, didSelectItemAtIndexPath indexPath: NSIndexPath) {
exercise_label="\(exercisesNames[indexPath.row])"
exercise_image="\(exercises_Exervise_Row_Names[indexPath.row])"
//self.dismissViewControllerAnimated(true, completion: nil)
closeMe()
}
@IBAction func done(sender: AnyObject) {
closeMe()
}
func closeMe(){
dismissViewControllerAnimated(true, completion: nil)
}