【问题标题】:UITextAutocapitalization fails after setting UITextfield to empty string将 UITextfield 设置为空字符串后 UITextAutocapitalization 失败
【发布时间】:2015-05-19 23:11:42
【问题描述】:

我已将我的搜索控制器/搜索栏设置为大写单词,它按预期工作。

设置使用

searchController.searchBar.autocapitalizationType = UITextAutocapitalizationType.Words

一旦按下空格键,下一个单词似乎是大写的。

我的问题是如果使用清除文本字段,

searchController.searchBar.text = ""

自动大写未激活(?因为我从未按过空格键)

我已经尝试了一些方法,例如

在清除字段之前添加一个空格

searchController.searchBar.text = " "
searchController.searchBar.text = ""

重置 firstResponder 以及 UITextAutocapitalizationType

searchController.searchBar.becomeFirstResponder()
searchController.searchBar.autocapitalizationType = UITextAutocapitalizationType.Words

都不行。

这是一个屏幕截图...

【问题讨论】:

    标签: ios swift uitextfield


    【解决方案1】:

    不知道为什么我不这样做,

    searchController.searchBar.resignFirstResponder()
    searchController.searchBar.becomeFirstResponder()
    

    问题已解决...

    如果有更好的方法请告诉我。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2017-11-05
      • 2016-01-31
      • 1970-01-01
      • 2011-04-07
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多