开发者

Activating the iphone keyboard

开发者 https://www.devze.com 2023-01-04 21:59 出处:网络
I cant believe that 开发者_高级运维I haven\'t been able to find any documentation on this yet but I was wondering how to command the keyboard to activate and receive input from it. All of the examples

I cant believe that 开发者_高级运维I haven't been able to find any documentation on this yet but I was wondering how to command the keyboard to activate and receive input from it. All of the examples I could find where for manipulating the keyboard that would pop up because of a text field being edited. Thanks


You can also use the UIKeyInput protocol to request a keyboard without having to create a hidden text field.

@interface My : UIViewController <UIKeyInput> ...

and then something like this in the implementation

// Methods which make the keyboard work

- (BOOL) hasText
{
    return YES;
}

- (void)deleteBackward
{
    [self handleBackspace];
}

- (void) insertText:(NSString* )text
{
    int n = [text length];
    int i;
    for (i = 0; i < n; i++)
    {
        [self handleKey:[text characterAtIndex:i]];
    }
}

- (BOOL) canBecomeFirstResponder
{
    return YES;
}

// Methods to manage the appearance of the keyboard

- (void) summonKeyboard
{
    [self becomeFirstResponder];
}

- (void) dismissKeyboard
{
    [self resignFirstResponder];
}


I eventually decided to create a text field that is hidden from view and was selected by:

[text_input becomeFirstResponder];
0

精彩评论

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