Hey guys, I only skimmed this thread since it is quite long, so I
don't know if what I have to say is helpful or not.
I had a problem before with a TTTableViewController where Three20's
keyboard resizing code did not work right. The problem is that Three20
assumes that the table goes all of the way to the bottom of the
screen, which is often not the case, for example when you have a tab
bar. The keyboard does always start are the bottom of the screen, but
the tableview may not. So I wrote some new code in my inherited class
to do the calculation correctly, and now it seems to do the right
thing in all cases.
I have not tried to resubmit this back into the project because
1) I am still learning GIT and this branching thing seems like it is
taking me hours to get right. Plus submission might require example
code of the bug and a demo app, and I don't have the time for it right
now.
2) I have already submitted a NIB fork, and spent more than 1 day on
that, but it has not paid off yet and until I see the NIB's in the
head I don't feel comfortable spending more time on submitting forks.
This is not a jab or anything, I really just don't want to do work
unless I know that it is going to be of value to other people.
Hopefully NIB's will appear in the head soon and then I will start
submitting some more bug fixes, such as this one.
Anyway, in case this code is useful, I am providing it here. Hopefully
this will work for you as well and solve your problem. If it does,
maybe someone can submit the changes to three20.
The solution requires you to track the delta of the bottom of the
table and the bottom of the screen. I am storing that difference in a
member field called mDeltaBottom of my inherited class.
@interface SubClass : TTTableViewController
{
float mDeltaBottom;
}
Also, as already noted in this thread, you have to set
self.autoresizesForKeyboard = YES;
Otherwise, I override the following methods in my inherited class as
so:
#pragma mark keyboard resizing
static int keyboardAdjustCount = 0;
/*
If we were to shrink the table view by the whole size of the
keyboard,
that would be too much, since the keyboard extends down below the
bottom
of the table. So we adjust the bounds of the keyboard so that its
height only
covers the amount of they keyboard that covers the table.
*/
-(CGRect)adjustKeyboardBounds:(CGRect)bounds
{
//DMV: TODO: it would be good to contribute this back to three20
//the three20 code assumes that the table goes all the way to the
bottom
//of the screen when resizing it for the keyboard. This change allows
us
//to only resize the part of the screen that overlaps the keyboard.
if (bounds.size.height > mDeltaBottom)
bounds.size.height -= mDeltaBottom;
else
bounds.size.height = 0;
return bounds;
}
/**
* Sent to the controller before the keyboard slides in.
*/
- (void)keyboardWillAppear:(BOOL)animated withBounds:(CGRect)bounds
{
mDeltaBottom = TTScreenBounds().size.height - self.view.height -
self.view.ttScreenY;
[super keyboardWillAppear:animated withBounds:bounds];
}
/**
* Sent to the controller before the keyboard slides out.
*/
- (void)keyboardWillDisappear:(BOOL)animated withBounds:(CGRect)bounds
{
keyboardAdjustCount--;
if (keyboardAdjustCount != 0)
{
TTDASSERT(NO);
return; //for some reason, we are being called too much
}
bounds = [self adjustKeyboardBounds:bounds];
[super keyboardWillDisappear:animated withBounds:bounds];
}
/**
* Sent to the controller after the keyboard has slid in.
*/
- (void)keyboardDidAppear:(BOOL)animated withBounds:(CGRect)bounds
{
if (keyboardAdjustCount != 0)
{
TTDASSERT(NO);
return; //for some reason, we are being called too much
}
keyboardAdjustCount++;
bounds = [self adjustKeyboardBounds:bounds];
[super keyboardDidAppear:animated withBounds:bounds];
//scroll to the new folder row
[self.tableView scrollToRowAtIndexPath:[self newShelfIndexPath]
atScrollPosition:UITableViewScrollPositionMiddle
animated:YES];
}
/**
* Sent to the controller after the keyboard has slid out.
*/
- (void)keyboardDidDisappear:(BOOL)animated withBounds:(CGRect)bounds
{
[super keyboardDidDisappear:animated withBounds:bounds];
}
I hope that I didn't leave any thing out. Let me know if this works
for you.