即使沒有足夠的時間來回應,我在2月份就明白了,現在iOS 8已經不再需要了。 不過,你這是怎麼加載自己的鍵盤:
%hook UIKeyboardInputMode
+ (id)keyboardInputModeWithIdentifier:(id)arg1 {
id o = %orig;
return o;
}
- (id)primaryLanguage {
if([TegakiLayout isTegaki:[self identifier]]) return @"Tegaki";
return %orig;
}
%end
%hook UIKeyboardImpl
/* This is where the magic is! */
+ (Class)layoutClassForInputMode:(NSString*)arg1 keyboardType:(int)arg2 {
Class sass = %orig;
if ([TegakiLayout isTegaki: arg1]) {
return [TegakiLayout class];
}
return sass;
}
%end
extern "C" NSArray*UIKeyboardGetSupportedInputModes();
extern "C" NSArray*UIKeyboardGetActiveInputModes();
static NSArray* (*orig_modes)();
NSArray* rep_modes() {
NSArray* res = [orig_modes() arrayByAddingObjectsFromArray:@[@"TEGAKI", @"TEGAKI_Graffiti"]];
return res;
}
static NSArray* (*orig_active_modes)();
NSArray* rep_active_modes() {
NSArray* res = orig_active_modes();
return res;
}
%ctor {
%init;
MSHookFunction(UIKeyboardGetSupportedInputModes, rep_modes, &orig_modes);
MSHookFunction(UIKeyboardGetActiveInputModes, rep_active_modes, &orig_active_modes);
}
其中TegakiLayout是UIKeyboardLayout的子類。
然後,您執行- (BOOL)isAlphabeticPlane
以返回它是否是傳統的鍵盤事物並在showKeyboardWithInputTraits:screenTraits:splitTraits:
中執行自定義視圖創建。
要輸入你然後使用[[UIKeyboardImpl activeInstance]insertText:@"\n"];
。
要創建一個「地球」按鈕使用此:
Class sw = NSClassFromString(@"UIInputSwitcherView");
[[sw sharedInstance]selectNextInputMode];
不要忘記實現-keyboardName
和-keyplaneName
以及! 我可能會在一天後發佈整個項目,但現在這裏描述的太大了。雖然這應該足以讓你啓動並運行。
我在這裏發現了一個有趣的回購:http://networkpx.googlecode.com/svn/trunk/hk.kennytm.iKeyEx3/src/ - 會讓你更新進度 –