views:

156

answers:

1

Hi all,

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 this

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.

+1  A: 
-(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];

}
Manjunath
Hi, Manjunath, thank you so much for your help, but I only want to set the contentinset of tableview such that cells go up by some 65px. I want the number to be set in UIEdgeInsetsMake for the "top". I'm applying the same code for the top of the tableview such that when the very first cell is pulled down, I'm displaying a view above it making it stay at 60 by doing self.tableView.contentInset = UIEdgeInsetsMake(60.0f, 0.0f, 0.0f,0.0f). Here I can directly set this at 60, but for the view after the last cell, I dont know whatvalue to pass:y-coord of offset of tableview/y-coord of screen.
neha
Checkout the edited answer and reply ASAP.
Manjunath
Awesome, Manjunath... Thanx it worked...!
neha