iOS----------UITextField實現過濾選中狀態拼音

來源:互聯網
上載者:User

標籤:oid   events   gre   一個   inf   列印   color   screen   gate   

2018年上班的第二天,就這樣背了一個大鍋。我們項目中有一個搜尋功能,在這一期的版本中,為了增強最佳化,去除了過濾空格的請求,這樣或許能增加很好的使用者體驗,恰恰相反,偷雞不成蝕把米。沒想到蘋果系統的IME竟然能自動聯想,在沒有選擇漢字的時候,竟然能聯想出來一大堆智能拼音,what???還有這種操作????輸就輸在了我幾乎不使用蘋果系統的IME,My Phone設定一般都是把蘋果的IME刪除了,直接使用搜狗。(蘋果系統的IME太難用了)

 

那現在就看一下沒有屏蔽拼音之前的輸入內容吧

 

當我輸入藍海的時候   還沒有選擇漢字呢   系統就會自動拼接一些拼音。

對比所列印的內容,有沒有覺得很驚喜?   怎麼樣才能把拼音去除掉呢? 給輸入框添加一個事件,在事件裡面過濾掉拼音   不信你可以試一下。

 

    _searchTextField = [[UITextField alloc]initWithFrame:CGRectMake(20, 100, kScreenWidth-40, 50)];

    _searchTextField.delegate = self;

    _searchTextField.backgroundColor = [UIColor orangeColor];

    _searchTextField.placeholder = @"輸入基金,快速定位";

    _searchTextField.returnKeyType = UIReturnKeyDone;

    _searchTextField.clearButtonMode = UITextFieldViewModeWhileEditing;

    [_searchTextField addTarget:self action:@selector(searchTextFieldChanges:) forControlEvents:UIControlEventEditingChanged];

    [self.view addSubview:_searchTextField];

 

- (void)searchTextFieldChanges:(UITextField *)textField{

    

    

    if (textField.markedTextRange == nil) {

        

        NSLog(@"選中了漢字之後出現的漢字:%@", textField.text);

 

    }

 

}

 

iOS----------UITextField實現過濾選中狀態拼音

相關文章

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.