Reputation: 619
I'm running into an issue which involves a table view and a keyboard. I have my program developed so that whens electing a table view, it scrolls the table view up past the keyboard, so that it can remain visible, by calculating the amount of scrolling up that is required to keep the text field visible, and then using a transform to move the frame that far up.
Since the UIView is still active, I can continue scrolling in the smaller view and select other text entries and make changes to them.
The problem occurs that I cannot see the bottom items in my list. I'd like to extend the "tolerance" for not scrolling to be equal to about the height of my keyboard, and then set it back to default after I dismiss my keyboard.
Thanks.
Upvotes: 0
Views: 789
Reputation: 9902
A nice way that might also look good is to not just scroll the tableView, but instead move the whole tableView (and maybe its surrounding view) up by the height of the keyboard (and, of course, down again upon dismissal).
myTableView.center = CGPointMake(myTableView.center.x, myTableView.center.y - keyboardHeight); //and vice versa for keyboard dismissal
If this works, you can experiment with animating it.
If you want to be able to scroll the tableView up further than ordinarily possible, you could try setting its contentSize
property prior to scrolling. Since UITableView
is a subclass of UIScrollView
, this should work if Apple didn't somehow override its behavior.
myTableView.contentSize = CGSizeMake(myTableView.contentSize.width, myTableView.contentSize.height + keyboardHeight); //and vice versa when keyboard is dismissed
Upvotes: 1
Reputation: 11174
why modify the frame of the table? you could just use the scrollToRowAtIndexPath:atScrollPosition:animated:
on UITableView and then you wouldn't have worry about modifying the frame of the tableview when the keyboard appeared and disappeared
Upvotes: 1