开发者

accessing/handling wireless keboard input(key press) in my ipad application

i have already done much googling on this neither i found a tutorial/way to accomplish this nor find that it could not be acheived(so that i can assist my client ,it's not possible) we have requirement to integrate a wireless keyboard in our existing ipad application. some of the scenarios are.... suppose you are having a uibutton on the view. then according to the requirement if user tap the key "entr/return" on the wireless keyboard the result is same as tapping the button on view.if user tap the key "i" on the wireless keyboard the result is same as tapping the information button (UIButtonTypeInfoDark) on view.

Means we have to handl wireless keyboard key press events.

any idea/link/tutorial would very helpful for this situa开发者_高级运维tion. thanks!


// Use the keyboard (<UIKeyInput>) class and provide for the delegates 
// required by this class
// Put the <UIKeyInput> at the end of the @interface line in the header file.
// Then make sure these methods are in your class as they are delegates 
// for the UIKeyInput class:

- (BOOL) canBecomeFirstResponder 
{
    return YES;
}
- (void) deleteBackward 
{

}

- (void) insertText:(NSString *)theText 
{

    theText = [theText capitalizedString];  // Ignore case
    const char *keyPressed = [theText UTF8String];
    switch(keyPressed[0])
    {
        case 'A':   // Do something associated with the 'A' key
            break;
        case '4':   // Do something associated with the '4' key
            break;
            // etc.
    }
}

- (BOOL) hasText 
{
    return YES;
}

-(void) endUserInput 
{

}
0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜