开发者

Detect space and space + shift key press on iPhone Keyboard

I'm trying to find a simple example to detect certain key events on the iPhone keyboard but 开发者_C百科am having trouble finding examples. Does anyone have simple examples? I'm attempting to do a simple substitution when the Space and Space+Shift keys are pressed.


You can use the shouldChangeTextInRange: delegate to detect characters:

-(BOOL)textView:(UITextView *)textView shouldChangeTextInRange:(NSRange)range replacementText:(NSString*)string {

    if([string isEqualToString:@"  +"]) {

        /* do something  */

    }
}
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜