I have a UITableView and I need to use a custom keyboard with it and, for a few re开发者_JAVA技巧asons, I can't use it as an inputView. So I am having a my keyboard view appear as a subview. Its height is 260. I want the table view to scroll so that the selected cell always has a y-position between 0 and 260. Is this possible? Here is what I am currently trying... (this is in the keyboard class)
-(void)showForCellAtIndexPath:(NSIndexPath*)indexPath{
[UIView beginAnimations:nil context:NULL];
self.view.frame = CGRectMake(0.0,220.0,320.0,260.0);
delegate.tableView.contentInset = UIEdgeInsetsMake(0.0,0.0,260.0,0.0);
delegate.tableView.scrollIndicatorInsets = delegate.tableView.contentInset;
delegate.view.frame = CGRectMake(0.0,-210.0, delegate.view.frame.size.width,delegate.view.frame.size.height);
[UIView commitAnimations];
[delegate.tableView scrollToRowAtIndexPath:indexPath atScrollPosition:UITableViewScrollPositionBottom animated:YES];
}
I would love your help. Thanks!
Alright...this solution is kind of a hack, but if someone searches and finds this, I don't want them to go thru the hell I did to figure it out.
What I did was modify the header height of the first section of the grouped table view to be large (300px was big enough for me). Then I changed the y-inset (in my case to -255), so that everything looked normal. When the user selects a section, I immediately eliminate the inset and do a scroll to bottom... Then, when the user hits done, I re-add the inset, so that the user doesn't have to go through extra scrolling.
I hope this helps anyone who has this same issue!
精彩评论