【问题标题】:UITextField sentence capitalize issue with becomeFirstResponder in iOSiOS 中的 becomeFirstResponder 的 UITextField 句子大写问题
【发布时间】:2015-02-28 10:38:30
【问题描述】:

我的 UIViewController 中有两个 UITextField。第一个 UITextField 用于包含数字,第二个 UITextField 用于包含文本。我在这里关心的是第二个有文本的 UITextField。我还为情节提要中的第二个 UITextField 启用了 Capitalization = Sentences

当我完成向第一个 UITextField 输入数值(退出时结束)时,我调用了一个方法,它具有以下逻辑

[sender resignFirstResponder];

if (_descriptionTextField.text.length == 0) {
        [_descriptionTextField becomeFirstResponder];
    }

正如我所料,第二个 UITextField 已准备好获取用户输入,但句子的第一个字母不是大写的。一段时间后(。)它会大写,如果我先点击第二个 UITextField 来输入文本,那么大写的东西也会起作用。

但是在我向第一个 UITextField 输入值后,我需要将句子大写,然后点击键盘上的下一步按钮,这将使第二个 UITextField 准备好输入值。我在哪里做错了?

【问题讨论】:

    标签: ios objective-c storyboard uitextfield capitalize


    【解决方案1】:

    试试这个代码

    if (_descriptionTextField.text.length == 0)
    
     {
    
    _descriptionTextField.autocapitalizationType = UITextAutocapitalizationTypeSentences;
    
            [_descriptionTextField becomeFirstResponder];
    
        }
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2018-08-31
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多