focus on UITextField inside a UICollectionViewCell

笑着哭i 提交于 2019-12-11 19:51:30

问题


I have created a custom UICollectionViewCell that contains a UITextField inside of it which is only accessible when the cell is selected. The CollectionView has multi select enabled and the problem is that when trying to select the UITextField to type in it, the cell is deselected instead of giving the TextField focus.

How do I allow focus on the UITextField inside of the CollectionViewCell without causing the cell to be deselected?

Note: I've also tried adding buttons to the cell template and the button actions are not getting called either. It seems as though the cell itself is capturing all of the touch events and not passing them along to child views.


回答1:


I'm not sure what the original problem was, but I solved it by re-creating the UICollectionViewCell interface inside the UICollectionView in my storyboard instead of loading it from a different .xib file.



来源:https://stackoverflow.com/questions/22436700/focus-on-uitextfield-inside-a-uicollectionviewcell

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!