I want to not enable the return button to be pressed on the keyboard whereas limiting the character depend to 200.
Drawback:
After I add restrictions to the UITextView, I can not copy and paste into the textView.
func textView(_ textView: UITextView, shouldChangeTextIn vary: NSRange, replacementText textual content: String) -> Bool {
//character restrict is about to 200
let newText = (textView.textual content as NSString).replacingCharacters(in: vary, with: textual content)
let numberOfChars = newText.depend
if(numberOfChars > 200){
return false
}
//take away return button keyboard performance
guard textual content.rangeOfCharacter(from: CharacterSet.newlines) == nil else {
return false
}
return true
}
Desired Output:
I want to nonetheless have the power to repeat and paste into the textView whereas sustaining the 2 restrictions.
I would love the power to disable the return key however nonetheless paste textual content with new strains.