简体   繁体   English

单击它们时TextFields没有响应! 这就像他们被粘在一起什么的?

[英]TextFields don't respond when I click on them! It's like they're glued or something?

Yo! 呦!

I have created a design in the Main.storyboard. 我在Main.storyboard中创建了一个设计。 I have a lot of views that I'm using to slideIn/slideOut etc. 我有很多观点,我正在使用slideIn / slideOut等。

The problem is that one of those views have some textfields. 问题是其中一个视图有一些文本字段。 None of them responds on click. 没有人对点击做出回应。 If I want to interact with them, I have to call 'becomesFirstResponder', but still, the other textfields are not able to respond on click. 如果我想与他们互动,我必须调用'becomeFirstResponder',但仍然,其他文本字段无法响应点击。

I've tried a lot with "bringSubViewToFront" etc, but nothing seems to work. 我已经尝试了很多“bringSubViewToFront”等,但似乎没有任何效果。 I don't know how to make those TextFields able to interact with. 我不知道如何使这些TextField能够与之交互。

They're all set delegate, enabled, and all of that. 他们都设置了委托,启用,以及所有这些。

    tv1.delegate=self
    tv2.delegate=self
    tv3.delegate=self
    tv4.delegate=self

What else can I try? 我还能尝试什么?

RIGHT, FINALLY! 对,最后!

I do NOT recommend this shitty solution. 我不推荐这种糟糕的解决方案。

But, if you suffer a problem similar to mine, just get it to work with this solution: 但是,如果您遇到类似于我的问题,只需使用此解决方案:

  1. Add button for ALL of your textFields. 为所有textField添加按钮。 Place them where your UITextFields are located and make the Buttons transparent in Attribute-inspector. 将它们放在UITextField所在的位置,并在Attribute-inspector中使Buttons透明。

  2. Add Action to the buttons in your ViewController-class and name them something "textField1_isEditing". 将Action添加到ViewController类的按钮中,并将其命名为“textField1_isEditing”。

  3. Inside the code-brackets, place following: yourTextFieldsName.becomesFirstResonder() 在代码括号内,放置以下内容: yourTextFieldsName.becomesFirstResonder()

  4. DONE! DONE! Now you can use a TextField that don't respond on buttonClicks, even if you have 100% sure set "userInteractionEnabled" "enabled" etc.. 现在你可以使用一个不响应buttonClicks的TextField,即使你有100%肯定设置“userInteractionEnabled”“启用”等。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM