iPhone:如何使UITextField不可见但仍可单击? [英] iPhone: How can I make a UITextField invisible but still clickable?
问题描述
我要做什么:
在一个简单的UITableView中,我有一个带有文本和日期/时间的表格,可以编辑.我也在日期/时间单元格中使用UITextFields,以便可以使用inputView属性在键盘上显示datePicker.
In a simple UITableView, I've got a form with both text and dates/times that can be edited. I'm using UITextFields in the date/time cells too, so that the inputView property can be used to display a datePicker over the keyboard.
问题出在哪里:
与此有关的问题是,这些UITextField实际上只是伪字段,在选择时会显示datePicker.选择它们后,它们会显示一个令人讨厌的蓝色光标,该指示灯闪烁-但它们只是虚拟的文本字段,我根本不希望它们变得可见.
The problem with this is that these UITextFields are really just dummy fields that show a datePicker when selected. When they're selected, they show this annoying blue cursor that blinks - but these are just dummy text fields, and I don't want them to become visible at all.
如果我将alpha设置为0或hidden = YES,则textField不再可单击.
If I set alpha = 0 or hidden = YES, then the textField no longer is clickable.
是否有解决此问题的想法-或者是解决我最初的问题的另一种方法?谢谢
Any ideas of a way around this - or, a different solution to my initial problem? Thanks
推荐答案
我终于想出了解决它的方法.通过隐藏UITextView,不会检测到任何触摸.但是,如果我叠加了一个自定义的UIButton(它是不可见的),那么当通过
I finally figured out a way around it. By hiding the UITextView, no touches are detected. However if I overlay a custom UIButton (which can be invisible) then I can activate the UITextField when the button is touched via
[myTextField becomeFirstResponder];
,然后datePicker将替换键盘.
and then the datePicker will replace the keyboard just like it should.
这篇关于iPhone:如何使UITextField不可见但仍可单击?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!