During the code review (see below) I found that you are actually resizing the table view to accomplish the effect. This is (in my opinion) not the right way to do it. Here is a suggestion:
Instead of adjusting the frame of the Table View simply work with the contentInset property. This is how UITableViewController does its job.
Short Code Review if you don't mind: (I only want to help - not to be a jerk)
Line 35:
Please remove your -init override. You are doing nothing there and if you want to have custom initialization use initWithCoder: and initWithFrame: instead of init
Line 61:
id (star)appDelegate = [[UIApplication sharedApplication] delegate];
Please remove the "(star)"
Line 64:
CGRect windowRect = appDelegate.window.bounds;
You are trying to get the window bounds. Why are you not using:
CGRect windowRect = self.window.bounds;
Line 73:
viewRectAbsolute = FixOriginRotation(viewRectAbsolute, orientation, windowRect.size.width, windowRect.size.height);
Are you aware of: CGRectGetHeight(…) and CGRectGetWidth(…)? I am not saying you should use these functions instead but you could consider using them. I like them very much:
Cool thanks! I'll look into those changes. I built this when I was learning iOS on the fly a year or so ago, so I'm sure things aren't all done in the absolute best fashion. I'll learn from your suggestions. Thanks!
Hopefully this is useful to someone. Obviously this could also just be a little display helper class (composition > inheritance) or even a category, but this was my original implementation. Might update it in the future. All the crazy coordinate stuff was the painful part.
Yes, if the tableView is your main view. Otherwise you are left rolling your own solution. In the case of the iPad, the tableView is rarely my main view for my controller, so I needed a little more flexible solution.
Per iOS standard design, only one ViewController is supposed to manage a full screen (iPhone) or region of a screen (iPad eg. split view controller). That's because you want to keep the view hierarchy pretty straightforward, instead of taking the view portions of other view controllers and inserting them as subviews of another VC. (Makes you feel dirty). Suggest watching the WWDC 2011 video on Customer Container VC's for an explanation.
Also it would be quite a bit of overkill and extra communication and code to back every table with a full blown view controller.
Ah, and after re-reading your question. Yes this was a design decision, but I've had to use this same bit within a detail controller inside a split view when I've had more than one table view.
The reasoning here was that search results aren't going to come up that often, so we wanted the results out of the way most of the time to make a cleaner interface.
Instead of adjusting the frame of the Table View simply work with the contentInset property. This is how UITableViewController does its job.
Short Code Review if you don't mind: (I only want to help - not to be a jerk)
Line 35: Please remove your -init override. You are doing nothing there and if you want to have custom initialization use initWithCoder: and initWithFrame: instead of init
Line 61: id (star)appDelegate = [[UIApplication sharedApplication] delegate];
Please remove the "(star)"
Line 64: CGRect windowRect = appDelegate.window.bounds;
You are trying to get the window bounds. Why are you not using: CGRect windowRect = self.window.bounds;
Line 73: viewRectAbsolute = FixOriginRotation(viewRectAbsolute, orientation, windowRect.size.width, windowRect.size.height);
Are you aware of: CGRectGetHeight(…) and CGRectGetWidth(…)? I am not saying you should use these functions instead but you could consider using them. I like them very much:
viewRectAbsolute = FixOriginRotation(viewRectAbsolute, orientation, CGRectGetWidth(windowRect), CGRectGetHeight(windowRect));
Line 79: int remainder = (viewRectAbsolute.origin.y + viewRectAbsolute.size.height + keyboardFrame.size.height) - windowRect.size.height;
Again: Consider the functions mentioned above. More importantly replace "int" with "NSInteger" - or even better with CGFloat.
Line 80: if (remainder > 0 && !(remainder > frame.size.height + 50)) {
When using CGFloat you want to make sure to use 0.0 and 50.0.
Line 82: float duration = [[userInfo objectForKey:UIKeyboardAnimationDurationUserInfoKey] doubleValue];
Why are you assigning the result of -doubleValue to a float?