Custom Keyboard (iPhone), UIKeyboardDidShowNotification and UITableViewController

Posted by Pascal on Stack Overflow See other posts from Stack Overflow or by Pascal
Published on 2010-03-12T16:49:59Z Indexed on 2010/03/13 23:45 UTC
Read the original article Hit count: 536

On an iPhone App, I've got a custom keyboard which works like the standard keyboard; it appears if a custom textfield becomes first responder and hides if the field resigns first responder. I'm also posting the Generic UIKeyboardWillShowNotification, UIKeyboardDidShowNotification and their hiding counterparts, like follows:

NSMutableDictionary *userInfo = [NSMutableDictionary dictionaryWithCapacity:5];
[userInfo setObject:[NSValue valueWithCGPoint:self.center]
             forKey:UIKeyboardCenterBeginUserInfoKey];
[userInfo setObject:[NSValue valueWithCGPoint:shownCenter]
             forKey:UIKeyboardCenterEndUserInfoKey];
[userInfo setObject:[NSValue valueWithCGRect:self.bounds]
             forKey:UIKeyboardBoundsUserInfoKey];
[userInfo setObject:[NSNumber numberWithInt:UIViewAnimationCurveEaseOut]
             forKey:UIKeyboardAnimationCurveUserInfoKey];
[userInfo setObject:[NSNumber numberWithDouble:thisAnimDuration]
             forKey:UIKeyboardAnimationDurationUserInfoKey];

[[NSNotificationCenter defaultCenter] postNotificationName:UIKeyboardWillShowNotification
                                                    object:nil
                                                  userInfo:userInfo];

This code is working and I use it in UIViewController subclasses.

Now since iPhone OS 3.0, UITableViewController automatically resizes its tableView when the system keyboards show and hide. I'm only now compiling against 3.0 and I thought that the controller should also resize the table if my custom keyboard appears, since I'm posting the same notification. However it doesn't. The table view controller is set as the delegate of the input fields.

Does anyone have an idea why this might be the case? Has anyone implemented something similar successfully?

I have standard input fields along the custom ones, so if the user changes the fields the standard keyboard hides and the custom one shows. It would be beneficial if the tableView didn't resize to full height and I didn't have to resize it back with a custom method.

© Stack Overflow or respective owner

Related posts about iphone

Related posts about cocoa-touch