【问题标题】:accessing/handling wireless keboard input(key press) in my ipad application在我的 ipad 应用程序中访问/处理无线键盘输入(按键)
【发布时间】:2011-09-22 14:58:06
【问题描述】:

我已经对此进行了很多谷歌搜索,既没有找到完成此任务的教程/方法,也没有发现无法实现(以便我可以帮助我的客户,这是不可能的)我们需要集成无线键盘在我们现有的 ipad 应用程序中。一些场景是....假设您在视图上有一个uibutton。然后根据要求,如果用户点击无线键盘上的“进入/返回”键,结果与点击视图上的按钮相同。如果用户点击无线键盘上的“i”键,结果与点击信息相同按钮 (UIButtonTypeInfoDark) 在视图中。

意味着我们必须处理无线键盘按键事件。

任何想法/链接/教程都会对这种情况非常有帮助。谢谢!

【问题讨论】:

  • 我想念这是一个用户体验问题
  • 这更像是一个程序问题。标记要移动。
  • @user340334 我已经在 stackoverflow 上发布了这个问题,但没有答案,这就是为什么我第一次尝试 UX,很抱歉给您带来不便,如果有人可以回答我吗??我什么都没有google了一整天的研发和搜索。希望有人能给我一个方向。。

标签: iphone


【解决方案1】:
// 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 
{

}

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2015-11-29
    • 2012-07-03
    • 1970-01-01
    • 2011-10-07
    • 2012-01-02
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多