// // CCKeyboard.m // CCFC // // Created by xichen on 11-12-23. // Copyright 2011 ccteam. All rights reserved. // #import "CCKeyboard.h" @implementation CCKeyboard + (UITextInputMode *)currentInputMode { return [UITextInputMode currentInputMode]; } + (NSString *)primaryLanguage { return [[UITextInputMode currentInputMode] primaryLanguage]; } // default rect in portrait mode + (CGRect)defaultPortraitKeyboardRect { return CGRectMake(0, 264, 320, 216); } // get the window of keyboard + (UIWindow *)getKeyboardWindow { NSArray *arr = [[UIApplication sharedApplication] windows]; for(UIWindow *temp in arr) { if([temp isMemberOfClass:NSClassFromString(@"UITextEffectsWindow")]) return temp; } return nil; } // get the view of the keyboard + (UIView *)getKeyboardView { UIWindow *window = [self getKeyboardWindow]; if(window != nil) { NSMutableArray *arr = [NSMutableArray array]; NSString *keyboardName = [self getKeyboardViewName]; [window getSubViewIsMemberOf:keyboardName array:arr maxSize:1]; if([arr count]) return [arr objectAtIndex:0]; return nil; } return nil; } // get the name of the keyboard + (NSString *)getKeyboardViewName { float sysVer = [[[UIDevice currentDevice] systemVersion] floatValue]; if(sysVer < 3.2) return @"UIKeyboard"; return @"UIPeripheralHostView"; } #if CC_ENABLE_PRIVATE_API + (NSString *)getCurrentInputMode { return (NSString *)UIKeyboardGetCurrentInputMode(); } + (NSString *)getLocalizedInputModeName:(NSString *)inputInternalName { return (NSString *)UIKeyboardLocalizedInputModeName(inputInternalName); } + (NSBundle *)getBundleForInputMode:(NSString *)inputInternalName { return (NSBundle *)UIKeyboardBundleForInputMode(inputInternalName); } + (NSArray *)getSupportedInputModes { return (NSArray *)UIKeyboardGetSupportedInputModes(); } + (Class)getInputManagerClassForInputMode:(NSString *)inputInternalName { return (Class)UIKeyboardInputManagerClassForInputMode(inputInternalName); } + (BOOL)isLayoutDefaultTypeForInputModeIsASCIICapable:(NSString *)inputInternalName { return UIKeyboardLayoutDefaultTypeForInputModeIsASCIICapable(inputInternalName); } + (BOOL)isInputModeUsesKBStar:(NSString *)inputInternalName { return UIKeyboardInputModeUsesKBStar(inputInternalName); } #endif @end
googlecode链接地址(会有更新):http://code.google.com/p/iphone-common-codes-ccteam/source/browse/trunk/CCFC/files/CCKeyboard.m
github地址:https://github.com/cxsjabc/iphone-common-codes-ccteam/tree/master/CCFC/files/CCKeyboard.m
CC键盘管理与输入模式操作
本文详细介绍了CC键盘管理类CCKeyboard的功能实现,包括获取当前输入模式、主要语言、默认键盘矩形区域等,并提供了获取键盘窗口和视图的方法。同时展示了如何使用不同版本系统下的键盘视图名称。

被折叠的 条评论
为什么被折叠?



