How to set the tableview's top using contentinset property while being at the bottom of the table
I'm having a tableview with 20 rows and 250 as their rowheight. While I'm at the bottom of the tableview, I want to shift the tableview upwards by 65px. I tried doing
self.tableView.contentInset = UIEdgeInsetsMake(-65.0f, 0.0f, 0.0f, 0.0f);
Also
self.tableView.contentInset = UIEdgeInsetsMake((4633.0f - 65.0f), 0.0f, 0.0f, 0.0f);
where 4633.0f is my contentoffset.y, but with no success.
When the last cell is pulled upwards, I'm showing a view below the last cell with an activity indicator on it to depict that more data is getting loaded. I need to keep that view visible for 3 seconds so I want to push the tableview cells up and after that I want to bring the tableview to its original position and reset the view below that.
I'm doing t开发者_JAVA百科his
EDIT: This' taking the tableview inset up in 2 seconds:
[UIView beginAnimations:nil context:NULL];
[UIView setAnimationDuration:0.2];
// self.tableView.contentInset = UIEdgeInsetsMake((4633.0f - 65.0f), 0.0f, 0.0f, 0.0f);
self.tableView.contentInset = UIEdgeInsetsMake(- 65.0f, 0.0f, 0.0f, 0.0f); //I want to know what should be written here
[UIView commitAnimations];
and then calling a function to reset it back as
This' bringing the tableview inset back in 3 seconds:
[UIView beginAnimations:nil context:NULL];
[UIView setAnimationDuration:.3];
[self.tableView setContentInset:UIEdgeInsetsMake(0.0f, 0.0f, 0.0f, 0.0f)];
[UIView commitAnimations];
Can anybody please suggest how to do it?
Thanx in advance.
-(void)yourMethod
{
[UIView beginAnimations:nil context:NULL];
[UIView setAnimationDelegate:self];
[UIView setAnimationDidStopSelector:@selector(animationDidStop:finished:context:)];
[UIView setAnimationDuration:0.2];
tableView.contentInset = UIEdgeInsetsMake(0, 0, 60, 0);
[UIView commitAnimations];
}
-(void)animationDidStop:(NSString *)animationID finished:(NSNumber *)finished context:(void *)context
{
[[self tableView] scrollToRowAtIndexPath:[[self tableView] indexPathForSelectedRow]
atScrollPosition:UITableViewScrollPositionBottom
animated:YES];
}
精彩评论