views:

26

answers:

1

Hello,

In my app I move the table view (in order to make the text fields visible when the keyboard appears). The view is looks following: alt text

This is the code I use for resizing the view and moving it up:

    static const NSUInteger navBarHeight = 44;
CGRect appFrame = [[UIScreen mainScreen] applicationFrame];
tableView.frame = CGRectMake(0, navBarHeight, appFrame.size.width, appFrame.size.height-navBarHeight-216); //216 for the keyboard

NSIndexPath *indPath = [self getIndexPathForTextField:textField]; //get the field the view should scroll to

[tableView scrollToRowAtIndexPath:indPath atScrollPosition:UITableViewScrollPositionMiddle animated:YES];

The problem is that when the view is moved up it also moves 3 pixels into right direction (it is hard to see the difference in the screenshot, but it is visible when the animation is on and I measured the difference with PixelStick tool). Here it is how it looks after the move: alt text

My analysis shows that scrolling the table does not influence the move to the right.

Any ideas what is wrong in the code above that makes the view move to the right?

A: 

Hi,

perhaps try changing this line :

tableView.frame = CGRectMake(0, navBarHeight, appFrame.size.width, appFrame.size.height-navBarHeight-216); //216 for the keyboard

to

tableView.frame = CGRectMake(tableView.frame.origin.x, navBarHeight, appFrame.size.width, appFrame.size.height-navBarHeight-216); //216 for the keyboard

just in case the origin.x of the tableview isn't at 0?

deanWombourne
Thank was it. Many thanks!
Jakub