开发者

UIKeyboard with iPhone OS 4

Hi I have a big problem with iPhone 4.0 OS with this code

if([[keyboard description] hasPref开发者_运维百科ix:@"<UIKeyboard"] == YES) {
}

in condition UIKeyboard it not working. I try "UILayoutContainerView" but it not working too.

please.


You can try this code:

- (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];
}

And you also need to add this code to function didFinishLaunchingWithOptions in AppDelegate:

[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(keyboardWillShow:) name:UIKeyboardWillShowNotification object:nil];


@"<UIPeripheralHostView" will work instead of @"<UIKeyboard"

Dunno why.

Can you tell me then: How to determine the keyboard type in the UIKeyboard class?

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜