I have an answer based on what is given above in Chaise.
The Chaise method does not allow you to enter two spaces in series - this is undesirable in some situations. Here you can completely disable the insertion of an automatic period:
Swift
In the delegate method:
func textView(_ textView: UITextView, shouldChangeTextIn range: NSRange, replacementText text: String) -> Bool {
Now you can press the spacebar as fast as you like by inserting only spaces.
Objective-c
In the delegate method:
- (BOOL) textView:(UITextView*)textView shouldChangeTextInRange:(NSRange)range replacementText:(NSString*)text
Add the following code:
//Check if a space follows a space if ( (range.location > 0 && [text length] > 0 && [[NSCharacterSet whitespaceCharacterSet] characterIsMember:[text characterAtIndex:0]] && [[NSCharacterSet whitespaceCharacterSet] characterIsMember:[[textView text] characterAtIndex:range.location - 1]]) ) { //Manually replace the space with your own space, programmatically textView.text = [textView.text stringByReplacingCharactersInRange:range withString:@" "]; //Make sure you update the text caret to reflect the programmatic change to the text view textView.selectedRange = NSMakeRange(range.location+1, 0); //Tell Cocoa not to insert its space, because you've just inserted your own return NO; }
simeon
source share