I found what I believe was the beginning of a solution. It seems that the coordinates that you and I see are based on the lower left or upper right corner, depending on whether the orientation is UIInterfaceOrientationLandscapeRight or UIInterfaceOrientationLandscapeLeft.
I donβt know why yet, but hopefully this helps. :)
[UPDATE] Therefore, I assume that the start of the window is 0.0 in normal portrait mode and rotates using ipad / iphone.
So, this is how I solved it.
First, I grab my orientation, the borders of the windows and spin my look in the window (with insidious coordinates)
UIInterfaceOrientation orientation = [[UIApplication sharedApplication] statusBarOrientation]; CGRect windowRect = appDelegate.window.bounds; CGRect viewRectAbsolute = [self.guestEntryTableView convertRect:self.guestEntryTableView.bounds toView:nil];
Then, if the orientation is landscape, I change the x and y coordinates, and the width and height
if (UIInterfaceOrientationLandscapeLeft == orientation ||UIInterfaceOrientationLandscapeRight == orientation ) { windowRect = XYWidthHeightRectSwap(windowRect); viewRectAbsolute = XYWidthHeightRectSwap(viewRectAbsolute); }
Then I call my function to fix the origin based on the upper left corner, regardless of the rotation of the ipad / iphone. It captures the origin depending on where the current 0.0 resides (depending on orientation)
viewRectAbsolute = FixOriginRotation(viewRectAbsolute, orientation, windowRect.size.width, windowRect.size.height);
Here are two functions that I use.
CGRect XYWidthHeightRectSwap(CGRect rect) { CGRect newRect; newRect.origin.x = rect.origin.y; newRect.origin.y = rect.origin.x; newRect.size.width = rect.size.height; newRect.size.height = rect.size.width; return newRect; } CGRect FixOriginRotation(CGRect rect, UIInterfaceOrientation orientation, int parentWidth, int parentHeight) { CGRect newRect; switch(orientation) { case UIInterfaceOrientationLandscapeLeft: newRect = CGRectMake(parentWidth - (rect.size.width + rect.origin.x), rect.origin.y, rect.size.width, rect.size.height); break; case UIInterfaceOrientationLandscapeRight: newRect = CGRectMake(rect.origin.x, parentHeight - (rect.size.height + rect.origin.y), rect.size.width, rect.size.height); break; case UIInterfaceOrientationPortrait: newRect = rect; break; case UIInterfaceOrientationPortraitUpsideDown: newRect = CGRectMake(parentWidth - (rect.size.width + rect.origin.x), parentHeight - (rect.size.height + rect.origin.y), rect.size.width, rect.size.height); break; } return newRect; }