Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/iphone/35.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
带iPhoneOS4的UI键盘_Iphone_Uikeyboard - Fatal编程技术网

带iPhoneOS4的UI键盘

带iPhoneOS4的UI键盘,iphone,uikeyboard,Iphone,Uikeyboard,嗨,我有一个很大的问题与iPhone 4.0操作系统与此代码 if([[keyboard description] hasPrefix:@"<UIKeyboard"] == YES) { } 在这种情况下,它不工作。我尝试UILayoutContainerView 但它也不起作用 请。您可以尝试以下代码: - (BOOL) findKeyboard:(UIView *) superView; { UIView *currentView; if ([superView.s

嗨,我有一个很大的问题与iPhone 4.0操作系统与此代码

if([[keyboard description] hasPrefix:@"<UIKeyboard"] == YES) {
}
在这种情况下,它不工作。我尝试UILayoutContainerView 但它也不起作用

请。

您可以尝试以下代码:

- (BOOL) findKeyboard:(UIView *) superView; 
{
    UIView *currentView;
    if ([superView.subviews count] > 0) {
        for(int i = 0; i < [superView.subviews count]; i++)
        {

            currentView = [superView.subviews objectAtIndex:i];
            NSLog(@"%@",[currentView description]);
            if([[currentView description] hasPrefix:@"<UIKeyboard"] == YES)
            {

                NSLog(@"Find it");

                return YES;
            }
            if ([self findKeyboard:currentView]) return YES;
        }
    }

    return NO;

}

-(void) checkKeyBoard {
    UIWindow* tempWindow;

    for(int c = 0; c < [[[UIApplication sharedApplication] windows] count]; c ++)
    {
        tempWindow = [[[UIApplication sharedApplication] windows] objectAtIndex:c];
        if ([self findKeyboard:tempWindow])
            NSLog(@"Finally, I found it");  
    }
}

- (void)keyboardWillShow:(NSNotification *)note {
    [self performSelector:(@selector(checkKeyBoard)) withObject:nil afterDelay:0];
}
不知道为什么


那么,您能告诉我:如何在UIKeyboard类中确定键盘类型吗?

您需要提供更多信息。你期望的结果是什么,你实际看到的结果是什么。解释它为什么不起作用,以及当它起作用时应该发生什么。你真的不应该像那样以编程方式使用描述方法。它用于在控制台和调试时向您显示一个良好的可读字符串。苹果可以随时更改描述的输出。也许你们在找的是一种阶级:?如果[keyboard isKindOfClass:[UIKeyboard class]]{…}我知道如何创建自定义键盘。如果有人想知道,请评论这篇文章^__^
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(keyboardWillShow:) name:UIKeyboardWillShowNotification object:nil];
@"<UIPeripheralHostView" will work instead of @"<UIKeyboard"