I have a view controller and a view. I then have a UIImageView created through IB and position using the IB Inspector. Setting the UIImageView’s frame to x and y coordinatates to 0 results in the image being placed top left of the view, below the status bar.
If I then implement viewDidLoad method of the view controller and set UIImageView ‘s frame position using:
myimageview.frame = CGRectMake(0, 0, 50, 50);
Which are exactly the same coordinates as defined for the UIImageView in IB, the image is moved up underneath the status bar. It seems the coordiantes when set via code are realtive to the Window and not the parent View as shown IB.
Anyone know why there is a decrepancy between IB and code?
Some useful debugging info:
Note: That width and height of the Image View is in fact 35×37. The above dimensions were just to simplify the orignal question.
The frame info before setting it in code:
2011-03-15 13:15:34.249 MyAPP [98288:207] {{0, 49}, {35, 37}}
The frame info after setting it in code:
2011-03-15 13:15:34.250 MyAPP [98288:207] {{0, 0}, {35, 37}}
As defined in Interface Builder:

As you can see IB says that the UIImageView X and Y coordinators are 0 ,0. While the debugging info above says that it’s actually 0, 49.
It seems that the problem I was having was due to a bug. I’ve rebuilt the UI in Interface Builder and now it works as expected.