Created
July 26, 2012 05:43
-
-
Save Moligaloo/3180458 to your computer and use it in GitHub Desktop.
Disable the return key of keyboard
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-(void)disableReturnKey{ | |
// Locate non-UIWindow. | |
UIWindow *keyboardWindow = nil; | |
for (UIWindow *testWindow in [[UIApplication sharedApplication] windows]) { | |
if (![[testWindow class] isEqual:[UIWindow class]]) { | |
keyboardWindow = testWindow; | |
break; | |
} | |
} | |
// Locate UIKeyboard. | |
UIView *foundKeyboard = nil; | |
for (UIView *possibleKeyboard in [keyboardWindow subviews]) { | |
// iOS 4 sticks the UIKeyboard inside a UIPeripheralHostView. | |
if ([[possibleKeyboard description] hasPrefix:@"<UIPeripheralHostView"]) { | |
possibleKeyboard = [[possibleKeyboard subviews] objectAtIndex:0]; | |
} | |
if ([[possibleKeyboard description] hasPrefix:@"<UIKeyboard"]) { | |
foundKeyboard = possibleKeyboard; | |
break; | |
} | |
} | |
[foundKeyboard performSelector:@selector(setReturnKeyEnabled:) withObject:NO]; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment