Reputation: 11
This is for graphic design reasons, so height in pixels is preferred. I think different language keyboards may have different heights if that is the case. Then height of USA/UK keyboard would be preferable?
Upvotes: 1
Views: 326
Reputation: 1364
You should get it programatically, it is the best way, register for the notification:
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector (keyboardDidShow:) name: UIKeyboardDidShowNotification object:nil];
And then get the frame:
-(void) keyboardDidShow: (NSNotification *)notif
{
NSDictionary* info = [notif userInfo];
NSValue *aValue = [info objectForKey:UIKeyboardFrameEndUserInfoKey];
CGRect keyboardFrame = [aValue CGRectValue];
}
Whish it helps!
Upvotes: 1
Reputation: 10182
You can get height of keyboard, whenever it gets showed:
//add this line to viewDidLoad
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(keyBordShown name:UIKeyboardDidShowNotification object:nil];
- (void)keyBordShown:NSNotification*)notification
{
NSDictionary* keyboardInfo = [notification userInfo];
NSValue* keyboardFrameBegin = [keyboardInfo valueForKey:UIKeyboardFrameBeginUserInfoKey];
CGRect keyboardFrameBeginRect = [keyboardFrameBegin CGRectValue];
}
As this will be better approach than statically setting height of keyboard.
Upvotes: 1