View is moved 3 pixels

Posted by Jakub on Stack Overflow See other posts from Stack Overflow or by Jakub
Published on 2010-05-07T14:34:45Z Indexed on 2010/05/07 14:38 UTC
Read the original article Hit count: 170

Filed under:
|
|

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?

© Stack Overflow or respective owner

Related posts about iphone

Related posts about iphone-sdk-3.0