Reputation: 547
I have a custom UICollectionViewCell
(let's call it MyCustomCell
) that has a custom UITextField
(let's call it MyCustomField
) inside it that users can add text to. However, it seems no matter what I do, the tap inputs don't get from the MyCustomCell
to its sub-view MyCustomField
. Previously, I had this same arrangement, except MyCustomCell
is a UITableViewCell
, and that worked for some reason.
Right now I had to do a workaround, where whenever a cell is tapped, the cell sends a becomeFirstResponder()
message to the textfield. However, this doesn't let the user tap on the "clear text" button inside the MyCustomField
, nor does it let the user move the cursor around in the text field:
// function inside the MyCustomCell, called by the view controller
// whenever it thinks the user tapped on a cell:
func cellTapped()
{
// this is an instance of MyCustomField:
input.becomeFirstResponder();
}
Is there any way to "pass" the actual gesture to the MyCustomField
(from either the MyCustomCell
, or from the the view controller that manages them both)?
Update: this is what the view hierarchy looks like for the MyCustomCell (sub-class of UICollectionViewCell):
Upvotes: 1
Views: 95
Reputation: 547
This may be of help to others who have similar issue: I believe @MultiColourPixel is correct in the comment above that there is a hidden "view" standing between the MyCustomField and MyCustomCell. What I did was:
MyCustomCell
and MyCustomField
.UICollectionViewCell
.becomeFirstResponder()
to the MyCustomField
.Upvotes: 1