In my iPad app, I noticed different behavior between iOS 6 and iOS 7 with UITextFields.
I create the UITextField as follows:
UIButton *theButton = (U
I've used Jack Song's answer for Swift 2 for a while until I realized that the non-braking spaces make problems when rendered in HTML elsewhere, as well as line breaking gets messy in the UITextView itself. So, I've improved the solution to have the non-bracking characters cleaned right away.
func textField(textField: UITextField, shouldChangeCharactersInRange range: NSRange, replacementString string: String) -> Bool {
if (textField == self.desiredTextField) {
var oldString = textView.text!
oldString = oldString.stringByReplacingOccurrencesOfString("\u{00a0}", withString: " ");
let newRange = oldString.startIndex.advancedBy(range.location)..