Hello, I'm here again!
I have a deadline soon and I have very annoying bug in front of me and no ideas, how to fix it. The problem is, that sometimes device doesn't know what it's orientation is before it has been rotated and so it messes up frames in conditional statements:
if (orient == UIInterfaceOrientationPortrait || orient == 0){
r = CGRectMake(0.0, 0.0, 320.0, 480.0);
// draw stuff
} else {
r = CGRectMake(0.0, 0.0, 480.0, 320.0);
// draw stuff
}
This bug can be easily reproduced if I keep device on the table or in hands (horizontal position) and run my application, it draws landscape-like rectangles in portrait type screen.
My questions are: can I somehow get the right orientation in this kind of situation? Too bad it can not be reproduced in simulator, so I'm not sure if the code I pasted is responsible for this bug, but that is the place where I fix view frames according to orientation. Maybe there's another (proper) way to do that? And maybe I can force application to be in portrait mode until rotation event will be fired?