1。遍历到到iPad上键盘的View
2010-05-17 16:33:42.849 AppForiPad[7279:207] ViewClass: <UIKeyboardAutomatic: 0xaa33160; frame = (0 0; 768 264); opaque = NO; layer = <CALayer: 0xaa332b0>>
2010-05-17 16:33:42.850 AppForiPad[7279:207] ViewClass: <UIKeyboardImpl: 0xaa2e1c0; frame = (0 0; 768 264); opaque = NO; layer = <CALayer: 0xaa33460>>
2010-05-17 16:33:42.852 AppForiPad[7279:207] ViewClass: <UIKeyboardLayoutStar: 0xaa3ab60; frame = (0 0; 768 264); layer = <CALayer: 0xaa3ad20>>
2010-05-17 16:33:42.853 AppForiPad[7279:207] ViewClass: <UIKBKeyplaneView: 0xaa54c30; frame = (0 0; 768 264); layer = <CALayer: 0xaa54d30>>
2010-05-17 16:33:42.854 AppForiPad[7279:207] ViewClass: <UIKBKeyView: 0xaa551b0; frame = (3 6; 63 62); opaque = NO; userInteractionEnabled = NO; layer =
UIKBKeyPlaneView为键盘的View;按键为UIKBKeyView;类文件可以参考:
http://github.com/kennytm/iphone-private-frameworks/tree/master/UIKit/
1-1 添加NSNotificationCenter
[[NSNotificationCenter defaultCenter] addObserver:self
selector:@selector(addCustomKeyBoardButton)
name:UIKeyboardWillShowNotification
object:nil];
1-2 - (void)addCustomKeyBoardButton {
for (id object in [[UIApplication sharedApplication] windows]) {
if ([object isKindOfClass:[UIWindow class]]) {
UIWindow *windows = (UIWindow *)object;
for (UIView *tmpView in windows.subviews) {
if ([tmpView.subviews count] > 0)
[self scanSubviewIn:tmpView];
}
}
}
}
1-3 - (void)scanSubviewIn:(UIView *)aView {
for (UIView *tmpView in aView.subviews) {
if([[tmpView description] hasPrefix:@"<UIKBKeyplaneView"] == YES) {
//do something to keyBoardView
for (UIView *keyboardButton in tmpView.subviews) {
if([[keyboardButton description] hasPrefix:@"<UIKBKeyView"] == YES) {
NSString *buttonName = [[keyboardButton key] name];
//do something to keyBoardButtonView
}
}
}
if ([tmpView.subviews count] > 0) {
[self scanSubviewIn:tmpView];
}
}
}
iPad按键名称和对应的Frame
竖屏:
2010-05-17 16:26:02.738 AppForiPad[7206:207] KeyName: Digit-1 Frame: (3,6,63,62)
2010-05-17 16:26:02.739 AppForiPad[7206:207] KeyName: Digit-2 Frame: (72,6,64,62)
2010-05-17 16:26:02.740 AppForiPad[7206:207] KeyName: Digit-3 Frame: (142,6,63,62)
2010-05-17 16:26:02.741 AppForiPad[7206:207] KeyName: Digit-4 Frame: (211,6,64,62)
2010-05-17 16:26:02.743 AppForiPad[7206:207] KeyName: Digit-5 Frame: (281,6,63,62)
2010-05-17 16:26:02.744 AppForiPad[7206:207] KeyName: Digit-6 Frame: (350,6,64,62)
2010-05-17 16:26:02.744 AppForiPad[7206:207] KeyName: Digit-7 Frame: (420,6,63,62)
2010-05-17 16:26:02.745 AppForiPad[7206:207] KeyName: Digit-8 Frame: (489,6,64,62)
2010-05-17 16:26:02.745 AppForiPad[7206:207] KeyName: Digit-9 Frame: (559,6,63,62)
2010-05-17 16:26:02.746 AppForiPad[7206:207] KeyName: Digit-0 Frame: (628,6,64,62)
2010-05-17 16:26:02.747 AppForiPad[7206:207] KeyName: Hyphen-Minus Frame: (32,72,63,60)
2010-05-17 16:26:02.748 AppForiPad[7206:207] KeyName: Solidus Frame: (101,72,63,60)
2010-05-17 16:26:02.748 AppForiPad[7206:207] KeyName: Colon Frame: (170,72,63,60)
2010-05-17 16:26:02.749 AppForiPad[7206:207] KeyName: Semicolon Frame: (239,72,63,60)
2010-05-17 16:26:02.749 AppForiPad[7206:207] KeyName: Left-Parenthesis Frame: (308,72,63,60)
2010-05-17 16:26:02.751 AppForiPad[7206:207] KeyName: Right-Parenthesis Frame: (377,72,63,60)
2010-05-17 16:26:02.752 AppForiPad[7206:207] KeyName: Primary-Currency-Sign Frame: (446,72,63,60)
2010-05-17 16:26:02.754 AppForiPad[7206:207] KeyName: Ampersand Frame: (515,72,63,60)
2010-05-17 16:26:02.755 AppForiPad[7206:207] KeyName: Commercial-At Frame: (584,72,63,60)
2010-05-17 16:26:02.755 AppForiPad[7206:207] KeyName: Full-Stop Frame: (207,136,62,60)
2010-05-17 16:26:02.755 AppForiPad[7206:207] KeyName: Comma Frame: (275,136,62,60)
2010-05-17 16:26:02.756 AppForiPad[7206:207] KeyName: Question-Mark Frame: (343,136,62,60)
2010-05-17 16:26:02.756 AppForiPad[7206:207] KeyName: Exclamation-Mark Frame: (411,136,62,60)
2010-05-17 16:26:02.759 AppForiPad[7206:207] KeyName: Apostrophe Frame: (479,136,62,60)
2010-05-17 16:26:02.761 AppForiPad[7206:207] KeyName: Quotation-Mark Frame: (547,136,62,60)
2010-05-17 16:26:02.762 AppForiPad[7206:207] KeyName: Delete-Key Frame: (698,6,67,62)
2010-05-17 16:26:02.764 AppForiPad[7206:207] KeyName: Undo-Key Frame: (71,136,130,60)
2010-05-17 16:26:02.766 AppForiPad[7206:207] KeyName: More-Key Frame: (3,200,198,60)
2010-05-17 16:26:02.768 AppForiPad[7206:207] KeyName: Unlabeled-Space-Key Frame: (207,200,334,60)
2010-05-17 16:26:02.771 AppForiPad[7206:207] KeyName: More-Key Frame: (547,200,150,60)
2010-05-17 16:26:02.774 AppForiPad[7206:207] KeyName: Dismiss-Key Frame: (703,200,62,60)
2010-05-17 16:26:02.776 AppForiPad[7206:207] KeyName: Return-Key Frame: (653,72,112,60)
2010-05-17 16:26:02.777 AppForiPad[7206:207] KeyName: Shift-Key Frame: (3,136,62,60)
2010-05-17 16:26:02.777 AppForiPad[7206:207] KeyName: Shift-Key Frame: (683,136,82,60)
横屏:
2010-05-17 16:29:08.091 AppForiPad[7206:207] KeyName: Digit-1 Frame: (4,9,85,79)
2010-05-17 16:29:08.092 AppForiPad[7206:207] KeyName: Digit-2 Frame: (97,9,85,79)
2010-05-17 16:29:08.101 AppForiPad[7206:207] KeyName: Digit-3 Frame: (190,9,85,79)
2010-05-17 16:29:08.102 AppForiPad[7206:207] KeyName: Digit-4 Frame: (283,9,85,79)
2010-05-17 16:29:08.103 AppForiPad[7206:207] KeyName: Digit-5 Frame: (376,9,85,79)
2010-05-17 16:29:08.105 AppForiPad[7206:207] KeyName: Digit-6 Frame: (469,9,85,79)
2010-05-17 16:29:08.107 AppForiPad[7206:207] KeyName: Digit-7 Frame: (562,9,85,79)
2010-05-17 16:29:08.108 AppForiPad[7206:207] KeyName: Digit-8 Frame: (655,9,85,79)
2010-05-17 16:29:08.109 AppForiPad[7206:207] KeyName: Digit-9 Frame: (748,9,85,79)
2010-05-17 16:29:08.110 AppForiPad[7206:207] KeyName: Digit-0 Frame: (841,9,85,79)
2010-05-17 16:29:08.113 AppForiPad[7206:207] KeyName: Hyphen-Minus Frame: (42,95,84,79)
2010-05-17 16:29:08.119 AppForiPad[7206:207] KeyName: Solidus Frame: (134,95,84,79)
2010-05-17 16:29:08.121 AppForiPad[7206:207] KeyName: Colon Frame: (226,95,84,79)
2010-05-17 16:29:08.123 AppForiPad[7206:207] KeyName: Semicolon Frame: (318,95,84,79)
2010-05-17 16:29:08.127 AppForiPad[7206:207] KeyName: Left-Parenthesis Frame: (410,95,84,79)
2010-05-17 16:29:08.130 AppForiPad[7206:207] KeyName: Right-Parenthesis Frame: (502,95,84,79)
2010-05-17 16:29:08.132 AppForiPad[7206:207] KeyName: Primary-Currency-Sign Frame: (594,95,84,79)
2010-05-17 16:29:08.133 AppForiPad[7206:207] KeyName: Ampersand Frame: (686,95,84,79)
2010-05-17 16:29:08.134 AppForiPad[7206:207] KeyName: Commercial-At Frame: (778,95,84,79)
2010-05-17 16:29:08.136 AppForiPad[7206:207] KeyName: Full-Stop Frame: (276,181,83,79)
2010-05-17 16:29:08.137 AppForiPad[7206:207] KeyName: Comma Frame: (367,181,82,79)
2010-05-17 16:29:08.139 AppForiPad[7206:207] KeyName: Question-Mark Frame: (457,181,83,79)
2010-05-17 16:29:08.140 AppForiPad[7206:207] KeyName: Exclamation-Mark Frame: (548,181,82,79)
2010-05-17 16:29:08.140 AppForiPad[7206:207] KeyName: Apostrophe Frame: (638,181,83,79)
2010-05-17 16:29:08.141 AppForiPad[7206:207] KeyName: Quotation-Mark Frame: (729,181,82,79)
2010-05-17 16:29:08.142 AppForiPad[7206:207] KeyName: Delete-Key Frame: (934,9,86,79)
2010-05-17 16:29:08.143 AppForiPad[7206:207] KeyName: Undo-Key Frame: (95,181,173,79)
2010-05-17 16:29:08.143 AppForiPad[7206:207] KeyName: More-Key Frame: (4,267,264,79)
2010-05-17 16:29:08.144 AppForiPad[7206:207] KeyName: Unlabeled-Space-Key Frame: (276,267,445,79)
2010-05-17 16:29:08.145 AppForiPad[7206:207] KeyName: More-Key Frame: (729,267,200,79)
2010-05-17 16:29:08.151 AppForiPad[7206:207] KeyName: Dismiss-Key Frame: (937,267,83,79)
2010-05-17 16:29:08.152 AppForiPad[7206:207] KeyName: Return-Key Frame: (870,95,150,79)
2010-05-17 16:29:08.153 AppForiPad[7206:207] KeyName: Shift-Key Frame: (4,181,83,79)
2010-05-17 16:29:08.158 AppForiPad[7206:207] KeyName: Shift-Key Frame: (909,181,111,79)
2010-05-17 16:29:11.168 AppForiPad[7206:207] KeyName: Digit-1 Frame: (4,9,85,79)
2010-05-17 16:29:11.169 AppForiPad[7206:207] KeyName: Digit-2 Frame: (97,9,85,79)
2010-05-17 16:29:11.170 AppForiPad[7206:207] KeyName: Digit-3 Frame: (190,9,85,79)
2010-05-17 16:29:11.172 AppForiPad[7206:207] KeyName: Digit-4 Frame: (283,9,85,79)
2010-05-17 16:29:11.173 AppForiPad[7206:207] KeyName: Digit-5 Frame: (376,9,85,79)
2010-05-17 16:29:11.174 AppForiPad[7206:207] KeyName: Digit-6 Frame: (469,9,85,79)
2010-05-17 16:29:11.176 AppForiPad[7206:207] KeyName: Digit-7 Frame: (562,9,85,79)
2010-05-17 16:29:11.177 AppForiPad[7206:207] KeyName: Digit-8 Frame: (655,9,85,79)
2010-05-17 16:29:11.178 AppForiPad[7206:207] KeyName: Digit-9 Frame: (748,9,85,79)
2010-05-17 16:29:11.179 AppForiPad[7206:207] KeyName: Digit-0 Frame: (841,9,85,79)
2010-05-17 16:29:11.181 AppForiPad[7206:207] KeyName: Hyphen-Minus Frame: (42,95,84,79)
2010-05-17 16:29:11.181 AppForiPad[7206:207] KeyName: Solidus Frame: (134,95,84,79)
2010-05-17 16:29:11.182 AppForiPad[7206:207] KeyName: Colon Frame: (226,95,84,79)
2010-05-17 16:29:11.183 AppForiPad[7206:207] KeyName: Semicolon Frame: (318,95,84,79)
2010-05-17 16:29:11.184 AppForiPad[7206:207] KeyName: Left-Parenthesis Frame: (410,95,84,79)
2010-05-17 16:29:11.185 AppForiPad[7206:207] KeyName: Right-Parenthesis Frame: (502,95,84,79)
2010-05-17 16:29:11.186 AppForiPad[7206:207] KeyName: Primary-Currency-Sign Frame: (594,95,84,79)
2010-05-17 16:29:11.187 AppForiPad[7206:207] KeyName: Ampersand Frame: (686,95,84,79)
2010-05-17 16:29:11.187 AppForiPad[7206:207] KeyName: Commercial-At Frame: (778,95,84,79)
2010-05-17 16:29:11.188 AppForiPad[7206:207] KeyName: Full-Stop Frame: (276,181,83,79)
2010-05-17 16:29:11.188 AppForiPad[7206:207] KeyName: Comma Frame: (367,181,82,79)
2010-05-17 16:29:11.189 AppForiPad[7206:207] KeyName: Question-Mark Frame: (457,181,83,79)
2010-05-17 16:29:11.189 AppForiPad[7206:207] KeyName: Exclamation-Mark Frame: (548,181,82,79)
2010-05-17 16:29:11.191 AppForiPad[7206:207] KeyName: Apostrophe Frame: (638,181,83,79)
2010-05-17 16:29:11.191 AppForiPad[7206:207] KeyName: Quotation-Mark Frame: (729,181,82,79)
2010-05-17 16:29:11.193 AppForiPad[7206:207] KeyName: Delete-Key Frame: (934,9,86,79)
2010-05-17 16:29:11.193 AppForiPad[7206:207] KeyName: Undo-Key Frame: (95,181,173,79)
2010-05-17 16:29:11.194 AppForiPad[7206:207] KeyName: More-Key Frame: (4,267,264,79)
2010-05-17 16:29:11.195 AppForiPad[7206:207] KeyName: Unlabeled-Space-Key Frame: (276,267,445,79)
2010-05-17 16:29:11.197 AppForiPad[7206:207] KeyName: More-Key Frame: (729,267,200,79)
2010-05-17 16:29:11.198 AppForiPad[7206:207] KeyName: Dismiss-Key Frame: (937,267,83,79)
2010-05-17 16:29:11.198 AppForiPad[7206:207] KeyName: Return-Key Frame: (870,95,150,79)
2010-05-17 16:29:11.200 AppForiPad[7206:207] KeyName: Shift-Key Frame: (4,181,83,79)
2010-05-17 16:29:11.201 AppForiPad[7206:207] KeyName: Shift-Key Frame: (909,181,111,79)