嗨,我有一个很大的问题与iPhone 4.0操作系统与此代码
if([[keyboard description] hasPrefix:@"<UIKeyboard"] == YES) {
}在条件UIKeyboard它不工作。我试过"UILayoutContainerView“,但它也不起作用。
请。
发布于 2010-09-13 12:48:52
你可以试试这段代码:
- (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];
}您还需要将以下代码添加到AppDelegate中的didFinishLaunchingWithOptions函数:
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(keyboardWillShow:) name:UIKeyboardWillShowNotification object:nil];发布于 2011-01-09 07:15:20
@"<UIPeripheralHostView" will work instead of @"<UIKeyboard"不知道为什么。
那么你能告诉我:如何确定UIKeyboard类中的键盘类型吗?
https://stackoverflow.com/questions/3609649
复制相似问题