How to customize position of the keyboard in iOS
First of all you need to write this code in -viewDidLoad method
-(void)keyboardWillAppear
{
{
CGRect rect=keyboard.frame;
rect.origin.y=rect.origin.y-60;
NSLog(@"points %@",rect);
keyboard.frame=rect
;
break;
}
}
}
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(keyboardWillAppear) name:UIKeyboardDidShowNotification object:nil];
After that create a method keyboardWillApear
{
UIWindow* tempWindow = [[[UIApplication sharedApplication] windows] objectAtIndex:1];
//Because we cant get access to the UIPeripheral throught the SDK we will just use UIView.
//UIPeripheral is a subclass of UIView anyways
UIView* keyboard;
//Iterate though each view inside of the selected Window
for(int i = 0; i < [tempWindow.subviews count]; i++){
//Get a reference of the current view
keyboard = [tempWindow.subviews objectAtIndex:i];
//Assuming this is for 4.0+, In 3.0 you would use "<UIKeyboard"
if(([[keyboard description] hasPrefix:@"<UIPeripheral"] == YES)||([[keyboard description] hasPrefix:@"<UIKeyboard"])) {
//Keyboard is now a UIView reference to the UIPeripheral we want
NSLog(@"Keyboard Frame: %@",NSStringFromCGRect(keyboard.frame));CGRect rect=keyboard.frame;
rect.origin.y=rect.origin.y-60;
NSLog(@"points %@",rect);
keyboard.frame=rect
;
break;
}
}
}
Comments
Post a Comment