专注于UICollectionViewCell内的UITextField [英] focus on UITextField inside a UICollectionViewCell

查看:124
本文介绍了专注于UICollectionViewCell内的UITextField的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我创建了一个自定义UICollectionViewCell,其中包含一个UITextField,只有在选中单元格时才能访问它。 CollectionView启用了多选,问题是当尝试选择要在其中键入的UITextField时,取消选择单元格而不是给予TextField焦点。

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.

如何做我允许专注于CollectionViewCell内部的UITextField,而不会导致取消选择单元格?

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.

推荐答案

我'我不确定原来的问题是什么,但我通过在故事板中的UICollectionView内重新创建UICollectionViewCell接口而不是从不同的.xib文件加载它来解决它。

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.

这篇关于专注于UICollectionViewCell内的UITextField的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆