Close to perfect disable iOS emoji emoji keyboard

Source: Internet
Author: User

Support iOS Sogou Input method and auto-associated emoticons (such as input hehe, out of the expression)

Note: Swift's TextView. text ! = Disable_emoji(textView. Text)

Use in OC! [XXX isequalstring:bbb]

reprint reserved (thank you): http://www.cnblogs.com/Leetvin/p/4384141.html

@IBOutlet Weak var tf: uitextfield!

override func viewdidload () {

Super. Viewdidload()

additional setup after loading the view, typically from a nib.

TF. AddTarget(self, action: "Textfielddidchange:", forControlEvents: uicontrolevents. editingchanged)

}

override func didreceivememorywarning () {

Super. Didreceivememorywarning()

//Dispose of any resources, can be recreated.

}

func textviewdidchange (textView: uitextview) {

var texttange = TextView. Selectedtextrange

if(TextView. Text ! = Disable_emoji(textView. Text))

{

TextView. text = Disable_emoji(textView. Text)

}

TextView. selectedtextrange = Texttange

}

func textfielddidchange (textField: Uitextfield) {

var texttange = TextField. Selectedtextrange

if(TextField. Text ! = Disable_emoji(textField. Text))

{

TextField. text = Disable_emoji(TextField. Text)

}

TextField. selectedtextrange = Texttange

}

func Disable_emoji (text:string),string

{

var regex = nsregularexpression(Pattern: "[^\\u0020-\\u007e\\u00a0-\\u00be\\u2e80-\\ua4cf\\ Uf900-\\ufaff\\ufe30-\\ufe4f\\uff00-\\uffef\\u0080-\\u009f\\u2000-\\u201f\r\n] ", Options: Nsregularexpressionoptions. caseinsensitive, Error: nil)

var modifiedstring = regex!. stringbyreplacingmatchesinstring(text, Options: nsmatchingoptions(), Range: nsmakerange( 0, text. Utf16count), Withtemplate: "")

return modifiedstring

}

Close to perfect disable iOS emoji emoji keyboard

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

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.