Reputation: 1210
I have a UICollectionView that contains custom cells like this:
class DurationDayCells: UICollectionViewCell{
@IBOutlet weak var dayLabel: UILabel!
@IBOutlet weak var dayHourText: UITextField!
}
I want the UICollectionView (and its container view to move up when the keyboard pops up for the text fields) and I used NSNotificationCenter
, keyboardWillShow
and keyboardWillHide
to do this, as in this tutorial: http://www.ioscreator.com/tutorials/move-view-behind-keyboard-ios8-swift
However, the problem is that when I try to dismiss the container view (the red view, with the upside down triangle UIButton) for the UICollectionView, the keyboard stays on screen, as shown in the screenshots:
What I want to do is to hide the keyboard when I dismiss the container view, in the IBAction function associated with the UIButton.
Upvotes: 0
Views: 1583
Reputation: 88
To add to the previous answer, you must change 'view' to the 'collectionview' e.g
self.collectionView.endEditing(true)
Upvotes: 0
Reputation: 2169
Try with a self.view.endEditing(true)
after dismissing the container view.
Upvotes: 2