【问题标题】:Editing mode issue in UITextfieldUITextfield 中的编辑模式问题
【发布时间】:2018-03-11 01:03:17
【问题描述】:

我在文本字段中使用 uipickerview。当我单击任何文本字段时,将显示 uipickerview,我们可以从 uipickerview 中选择任何值。

所以,我的问题是。当我单击文本字段时,uipicker 会出现,并且会显示文本字段编辑模式。

所以,当我单击 HelpTopics 文本字段时,选择器即将到来,并且它在文本字段中显示编辑模式。 怎么解决。我的意思是,我不想要那种编辑选项模式。 当我单击文本字段时,只会显示选择器,这就是我想要的。 怎么做 ?

【问题讨论】:

  • 如何在文本字段点击中显示pickerview?表示您已在显示pickerview 的文本字段开始方法中的 OR 上放置了透明按钮

标签: ios objective-c iphone uitextfield uipickerview


【解决方案1】:

只写一行

斯威夫特

yourTextFieldObject.tintColor = .clear // "yourTextFieldObject" is "HelpTopics" textField's object

Objective-C

yourTextFieldObject.tintColor = [UIColor clearColor]; // "yourTextFieldObject" is "HelpTopics" textField's object

但是上面的代码你的 textField 光标颜色会清晰,不会显示。

【讨论】:

  • 非常感谢您的回答。它按照我的要求工作。
  • @KaranPatil 很高兴为您提供帮助:)
【解决方案2】:

Swift 3+: 使用这个 UITextFieldDelegate 方法。只写这行。

func textFieldDidBeginEditing(_ textField: UITextField) {
            if textField == yourTextField{
                textField.resignFirstResponder()
             // Open your picker here.
            }
        }

【讨论】:

  • 通过此代码 UIPickerView 将不会显示,因为 OP 可能会在 inputView 中添加 pickerView 这就是原因
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 2011-10-19
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2015-07-25
  • 1970-01-01
相关资源
最近更新 更多