Created
July 23, 2016 11:06
-
-
Save canaksoy/2e2b810783507bec7a170c005707e7d2 to your computer and use it in GitHub Desktop.
shouldChangeTextInRange (user is typing logic)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@property int isTyping; | |
- (BOOL)textView:(UITextView *)textView shouldChangeTextInRange:(NSRange)range replacementText:(NSString *)text { | |
[self startTyping]; | |
[NSObject cancelPreviousPerformRequestsWithTarget:self selector:@selector(stopTyping) object:nil]; | |
[self performSelector:@selector(stopTyping) withObject:nil afterDelay:0.5]; | |
return YES; | |
} | |
- (void)startTyping { | |
if (self.isTyping==0) { | |
self.isTyping=1; | |
[self sendTypingStartData]; | |
} | |
} | |
- (void)stopTyping { | |
self.isTyping=0; | |
[self sendTypingStopData]; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment