0

On iPad following is offscreen when in portrait, why this even when starting up in portrait?

- (void)viewDidLoad
{
    [super viewDidLoad];

    UIView* imageView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, 50, 50)];
    blue.backgroundColor = [UIColor blueColor];
    [[self view] addSubview:imageView];

I have been told that the root view's frame is always the same in portrait and landscape: - portrait frame orign(x i representing the orign of an UIView)
x0
00
00

Landscape frame orign:
000
x00

But why is CGRectMake(0,0 .. not up in the right corner in portrait?

Thanks in advance

1
  • bounds are the same always, frame does change on rotations, etc. Also the origin is always the top left corner, independent you current device orientation
    – Templar
    Jul 20, 2012 at 8:48

1 Answer 1

0

The bounds and the frame can change when you rotate the device. Let's take a Single View Application template as an example, add orientation support and run it on the iPhone. In portrait:

bounds = (0, 0, 320, 460) // 460 compensates for 20p status bar
frame = (0, 20, 320, 460) // status bar adjustment
x0
00
00

In landscape:

bounds = (0, 0, 480, 300) // now 20p is taken from "height"
frame = (20, 0, 300, 480) // status bar adjustment
x00
000

Origin is always top-left corner, regardless of orientation.

1
  • - (void)viewDidLoad is always Portrait though & [[UIScreen mainScreen] applicationFrame] is always Portrait
    – Chris G.
    Jul 20, 2012 at 22:45

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.