0
votes

I have this code inside a UIViewController subclass:

- (id)init {
    self = [super init];

    if (self) {            
        self.view.frame = [PDToolbox screenFrame];
        self.view.autoresizingMask = UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight;

        self.view.backgroundColor = [UIColor redColor];
    }

    return self;
}

The only thing I have in terms of any rotation methods is this:

-(BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation {
    return YES;
}

Yet after the screen is rotated to landscape, doing an NSLog on the view shows this:

<UIView: 0x10061640; frame = (0 0; 320 480); transform = [0, -1, 1, 0, 0, 0]; autoresize = W+H; layer = <CALayer: 0x10061670>>

I don't understand why it's doing this transform thing, and not just rotating like normal? It means any views i place on top of it after the rotation and set to be the size of the view end up at a 320x480 position.

EDIT:

People aren't understanding. So I put a view on top of it, the same size as the UIView, using:

UIView *anotherView = [UIView alloc] initWithFrame:controller.view.bounds];
[controller.view addSubview:anotherView];

If I add anotherView in in portrait, anotherView appears in portrait, with the frame 320x480.

If i add anotherView in in landscape, anotherView appears in landscape, but still with the frame 320x480, becaus that's what the controller.view's frame is still, for some unknown reason.

2
Could you just post a whole code of your UIViewCOntrollerDinesh Raja
@R.A Sure. Just done it.Andrew
Actually i dont understand your problem..What do you mean by this?"views i place on top of it after the rotation and set to be the size of the view end up at a 320x480 position"Dinesh Raja
Are you adding this view directly to the window or something? This is very odd behaviour that's typically managed (correctly) by your view controller hierarchy.Ash Furrow

2 Answers

0
votes

What does your view/controller hierarchy look like? It looks to me like something is setting a 90° rotation transformation on your view, rather than changing the view's frame. If you're not doing that yourself, it's likely a parent view or view controller.

0
votes

Frame and bounds are very different things. You should read Apple's guide to View Geometry - it contains a lot of information that's been invaluable to me.

Your bounds is always going to be 320x480 because someone is setting your transform (which affects the frame, but not the bounds).

Make sure your view controller's view's superview has autoresizesSubviews set to YES and that any subviews added have appropriate autoresizingMasks.